User:Generalantilles/rm you

Hey, it's rm_you!

Check out Advanced Backlight Statusbar Applet!



[edit] IRC with Timeless concerning GTK stuff with the sound applet:

rm_you: open the official sound statusbar applet code

rm_you: search for hildon_hvolumebar_new

timeless: Searching...

timeless: ok

timeless: Found one matching line

rm_you: and then once you know what the name of that object is, find what container they add it to

rm_you: then all I need to know is what type of container it is

timeless: it gets munged by gtk_box_pack_start

rm_you: gtk_box_pack_start... ok

rm_you: into what kind of box

rm_you: and what does that box get added to

timeless: gtk_vbox_new (false, 5)

timeless: and into the soundwindow, whatever that is

rm_you: ok, so they put the "hildon_hvolumebar_new" object into a "gtk_vbox_new" object

rm_you: and that gets added to... a "soundwindow"?

timeless: g_object_new (... "statusbar-item" ...)

rm_you: ... what?

timeless: yeah a SOUND_TYPE_WINDOW

rm_you: can you do a search for "gtk_menu"

timeless: oh. yeah, essentially this re-implements and delegates to things :)

rm_you: ?

timeless: basically the sound_window thing acts almost like a gtkmenu container

timeless: and special handles things to make it all work :)

rm_you: ....

timeless: e.g. it has a set_focus method which will call gtk_menu_item_(de)select on things

rm_you: so

rm_you: but

rm_you: but

rm_you: but

rm_you: WHAT!?

timeless: sorry, I'm definitely not copying the rest of the code

timeless: but yeah, pretty much, that's it :)

timeless: oh yeah... the window calls gtk_window_set_type_hint(...., GDK_WINDOW_TYPE_HINT_MENU)

rm_you: yeah but... there must be something special... I *tried* putting the hildon_hvolumebar_new object into a vbox into a GtkMenu/GtkMenuItem

rm_you: it doesn't work

rm_you: so they have a custom implementation of GtkMenu?

timeless: yep

rm_you: that's... ridiculous

rm_you: is it in the statusbar code? or is it in a library?

timeless: it's in the same file as far as I can tell

rm_you: <_<

timeless: but there's no way I can justify sharing it

rm_you: how long is it

rm_you: <_<

timeless: you should just instrument gtk

rm_you: just tell me as much as you can ABOUT it

timeless: it's not that hard

rm_you: I tried asking people in #gtk+

rm_you: multiple people told me either that what I wanted to do wasn't possible without some serious hackage, or that I would have to rewrite my own gtkmenu system

timeless: I mean, this should be fairly easy... you either use a perl script to rewrite the library entry points

timeless: or use a debugger to dynamically do it

timeless: either way, it's fairly trivial

timeless: all you need is for each gtk method to spit out at entry all strings and all pointers, and at exit to spit out any returned pointers

timeless: from there since everything is a gtk call, you can find out which methods are called in order for each object

rm_you: htm

timeless: it is "serious" hackage, but it's fairly automatable

timeless: so it's not "hard" hackage

timeless: more like "thorough"

rm_you: hrm. I don't think I know enough about GTK to do that though. :(

rm_you: I'll have to find help

rm_you: though duplicating that is ridiculous

rm_you: Nokia has no reason to keep that closed

rm_you: in fact, it should probably be a separate library, eg HildonMenu

  • timeless nods

rm_you: and be put into libhildon

timeless: I might give you perl that would hack gtk_ for this...

timeless: it really shouldn't be that bad

rm_you: I tried rewriting GtkMenu / GtkMenuItem last week

rm_you: it turned into a nightmare

rm_you: I don't know nearly enough about the inner workings of GTK to mess with that stuff <_<

timeless: well... you'd want something like:


  1. !/usr/bin/perl

unless (/^gtk_.*_set_/) { print; next; }

if (/\((.*)\)/) {

  1. one line case - not implemented because afaict, gtk doesn't use it

} elseif (/\((.*)/) {

  1. multi line case

my @args = ();

some_looping_here:

/\((?:const\s+|)(\S+)\s+(\*|)(\S+)([.)])/;

my ($type, $pointer, $name, $more) = ($1, $2, $3, $4);

push @args, $name;

$types{$name} = $type;

$pointers{$name} = $pointer;

goto some_looping_here if ($more eq ',');

  1. oops, probably would have been a good idea to read another line from input before doing that goto :)
  1. some perl assembly required ;-)
  1. at this point we've reached a line that ends in )
  1. we probably should have been printing the lines somewhere too... oh well, more assembly required
  1. eat the next line

<>;

die "i was really hoping to see an open brace ..." unless /^[{]/;

foreach my $arg (@args) {

if ($pointers{$arg}) { print qq#fprintf(stderr, "$arg %p ", $arg);\n#; }

elseif ($types{$arg} =~ /int$/i) { print qq#fprintf(stderr, "$arg %d, ", $arg);\n#; }

else {

  1. hrm, better work could be used here, you'll have to figure out what other creatures there are... you probably wanted to special case char before pointer :)

print qq#fprintf(stderr, "$arg %p, ", & $arg);\n#; }

}

print qq#fprintf(stderr, "\n");\n#;

  1. ok... thats a draft for the head
  1. in theory you'd want to deal w/ gtk_new and anything else that creates a pointer, but in practice, you won't really need it
  1. the goal is basically perl myscript.pl < gtkmenu.c > gtkmenu-evil.c

[edit] Emails from Timeless concerning GTK stuff with applets:

On Wed, May 7, 2008 at 7:38 AM, Adam Harwell <aharwell at trinity.edu> wrote:

>> The binary package osso-statusbar-sound contains a statusbar applet that can

>> be used to control the volume level of the system. It consists primarily of

>> some GtkContainer or HildonContainer object that can be used as a

>> popup/popdown menu. That object then contains a "hildon_hvolumebar" as well

>> as a menu item of some kind that launches the sound configuration

>> controlpanel applet.

>>

>> Currently I am using a "hildon_desktop_popup_window". This sort of works,


what follows is JavaScript notation based on C GObject code.


function SoundWindow() {

var box = new gtk["vbox"];

gtk["container"].add (this, box);

box.pack([volumebar, ...]);

}

SoundWindow.prototype = {

type_hint: GDK_WINDOW_TYPE_HINT_MENU,

name: "hildon-status-bar-popup",

resizable: false,

decorated: false,

/* i think this is the cute border you're asking about, and yes, it

seems like it's just hard coded into the C */

border_width: 20,

keep_above: true

}



fwiw, the same general approach is used by the display applet.

>> but it lacks the nice thick border and rounded corners that the default

>> sound applet uses, as well as some intelligent autoclose functions. Can you

>> find out if there is some kind of hildon container that is being used for

>> the default sound applet?