== Disclaimer ==
Written around 5 am using a crappy internet connection.
== 1 ==
In setup_dialog_settings() you seem to use an old way to initialize the theme setting. I only took a quick look at the code, but if you have a .ui (GtkBuilder) file, then you can use:
prefs is a gtk.Builder object here. You can then use self.applet.settings["theme"] or use the GProps object returned by load_bindings(); if you choose this, use it something like this:
And then you should be able to use it like this: print self.settings.theme or self.settings.theme = "Tango" to read or write the setting.
In this case you need to create the combobox in the .ui file (not manually) with a model (GtkListStore) that needs a gchararray field/column. Then after having set-up the bindings, you need to fill the combobox with some text elements:
combobox_theme = prefs.get_object("combobox-theme")
awnlib.add_cell_renderer_text(combobox_theme)
for i in self.themes:
combobox_theme.append_text(i)
self.themes is a list of strings here. Note that a call to add a cell renderer is needed, because the Glade tool doesn't seem to provide a way to set it in the .ui file.
Look in load_theme_pref() in volume-control.py how you could do this.
== 2 ==
I also noticed that you seem to set pixbufs as icons via self.applet.icon.set(). I think it's better to use Awn's themed icon API (moonbeam will agree :p) if possible. To do this, when initializing the icons (see setup_icons() in volume-control.py), first set the states:
self.applet.theme.set_states(states)
where states is a dict mapping the state names to the icon names. Second, you set the theme:
self.applet.theme.theme(theme)
theme must be None here if you want to use the user's current system theme. (In volume-control.py in setup_icons() I add "System theme" to the combobox, and then make theme None if the theme name matches "System theme")
Later, when you want to change the icon, set the icon to one of the states that you gave set_states():
self.applet.theme.icon(icon_state)
I call the setup_icons() method every time the combobox (theme) value changes. After that, you can change the icon (by changing the current state) whenever you want.
Btw, you need to change the folder adium-dock-themes/ to themes/ then. Also make sure Green/ and Purple/ both have each an index.theme file. And probably the images need to be in some directory with a famous/known name to get the bloody gtk icon code (used by the Awn themed icon API) to find the images. (I use themes/<theme name>/scalable/
If you use this themed icon API shizzle, then you can remove the call self.applet.connect_size_changed(self.size_changed_cb)
== 3 ==
Oh, and use if x is None (or if x) instead of if x == None
and if x is not None (or if not x) instead of if x != None
in setup_context_menu(). Don't do this, you can just do:
menu = self.applet.dialog.menu
menu_index = len(menu) - 1
And then do menu.insert(<your item>, menu_index + <some index>)
Then add a gtk.SeparatorMenuItme() and then call self.applet.dialog.new("preferences") so that you get some items, a separator, and then Preferences and About (last 2 are added automatically)
== 5 ==
Change name of procedure RefreshIcon to refresh_icon. Check code for PEP8 compliance.
== Disclaimer ==
Written around 5 am using a crappy internet connection.
== 1 == settings( ) you seem to use an old way to initialize the theme setting. I only took a quick look at the code, but if you have a .ui (GtkBuilder) file, then you can use:
In setup_dialog_
binder = self.applet. settings. get_binder( prefs) bind("theme" , "combobox-theme", key_callback= self.combobox_ theme_changed_ cb) settings. load_bindings( binder)
binder.
self.applet.
prefs is a gtk.Builder object here. You can then use self.applet. settings[ "theme" ] or use the GProps object returned by load_bindings(); if you choose this, use it something like this:
self.settings = self.applet. settings. load_bindings( binder)
And then you should be able to use it like this: print self.settings.theme or self.settings.theme = "Tango" to read or write the setting.
In this case you need to create the combobox in the .ui file (not manually) with a model (GtkListStore) that needs a gchararray field/column. Then after having set-up the bindings, you need to fill the combobox with some text elements:
combobox_theme = prefs.get_ object( "combobox- theme") add_cell_ renderer_ text(combobox_ theme) theme.append_ text(i)
awnlib.
for i in self.themes:
combobox_
self.themes is a list of strings here. Note that a call to add a cell renderer is needed, because the Glade tool doesn't seem to provide a way to set it in the .ui file.
Look in load_theme_pref() in volume-control.py how you could do this.
== 2 == icon.set( ). I think it's better to use Awn's themed icon API (moonbeam will agree :p) if possible. To do this, when initializing the icons (see setup_icons() in volume-control.py), first set the states:
I also noticed that you seem to set pixbufs as icons via self.applet.
self.applet. theme.set_ states( states)
where states is a dict mapping the state names to the icon names. Second, you set the theme:
self.applet. theme.theme( theme)
theme must be None here if you want to use the user's current system theme. (In volume-control.py in setup_icons() I add "System theme" to the combobox, and then make theme None if the theme name matches "System theme")
Later, when you want to change the icon, set the icon to one of the states that you gave set_states():
self.applet. theme.icon( icon_state)
I call the setup_icons() method every time the combobox (theme) value changes. After that, you can change the icon (by changing the current state) whenever you want.
Btw, you need to change the folder adium-dock-themes/ to themes/ then. Also make sure Green/ and Purple/ both have each an index.theme file. And probably the images need to be in some directory with a famous/known name to get the bloody gtk icon code (used by the Awn themed icon API) to find the images. (I use themes/<theme name>/scalable/
If you use this themed icon API shizzle, then you can remove the call self.applet. connect_ size_changed( self.size_ changed_ cb)
== 3 ==
Oh, and use if x is None (or if x) instead of if x == None
and if x is not None (or if not x) instead of if x != None
== 4 ==
Last thing: you seem to do
self.popup_menu = self.applet. create_ default_ menu() menu.show_ all()
self.popup_
in setup_context_ menu(). Don't do this, you can just do:
menu = self.applet. dialog. menu
menu_index = len(menu) - 1
And then do menu.insert(<your item>, menu_index + <some index>)
Then add a gtk.SeparatorMe nuItme( ) and then call self.applet. dialog. new("preference s") so that you get some items, a separator, and then Preferences and About (last 2 are added automatically)
== 5 ==
Change name of procedure RefreshIcon to refresh_icon. Check code for PEP8 compliance.
http:// wiki.awn- project. org/Applets: DevelopmentGuid elines# Python_ PEP_8