diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-06-09 12:13:59 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-06-09 12:13:59 +0100 |
commit | 664a45a398020f82f1e8f8e22f1627392a06a0c2 (patch) | |
tree | 43bd6bcccc4f5b63937ffcaa96c38b04bbd07623 | |
parent | 744083d4483291a87f4f348d6937257d8887cfb1 (diff) | |
download | ayatana-indicator-sound-664a45a398020f82f1e8f8e22f1627392a06a0c2.tar.gz ayatana-indicator-sound-664a45a398020f82f1e8f8e22f1627392a06a0c2.tar.bz2 ayatana-indicator-sound-664a45a398020f82f1e8f8e22f1627392a06a0c2.zip |
buttons added - events being received
-rwxr-xr-x | src/indicator-sound.c | 112 | ||||
-rw-r--r-- | src/transport-bar.c | 45 | ||||
-rw-r--r-- | src/transport-bar.h | 7 |
3 files changed, 94 insertions, 70 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c index e13c52b..48fde56 100755 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -38,7 +38,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libindicator/indicator-image-helper.h> #include "indicator-sound.h" -#include "transport-bar" +#include "transport-bar.h" #include "dbus-shared-names.h" #include "sound-service-client.h" #include "common-defs.h" @@ -62,7 +62,7 @@ struct _IndicatorSoundClass { //GObject instance struct struct _IndicatorSound { IndicatorObject parent; - GtkWidget *slider; + GtkWidget *slider; IndicatorServiceManager *service; }; // GObject Boiler plate @@ -166,17 +166,17 @@ indicator_sound_init (IndicatorSound *self) { self->service = NULL; self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); - prepare_state_machine(); - prepare_blocked_animation(); - animation_id = 0; - blocked_id = 0; - initial_mute = FALSE; - device_available = TRUE; - slider_in_direct_use = FALSE; - exterior_vol_update = OUT_OF_RANGE; + prepare_state_machine(); + prepare_blocked_animation(); + animation_id = 0; + blocked_id = 0; + initial_mute = FALSE; + device_available = TRUE; + slider_in_direct_use = FALSE; + exterior_vol_update = OUT_OF_RANGE; g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); - return; + return; } static void @@ -188,9 +188,9 @@ indicator_sound_dispose (GObject *object) g_object_unref(G_OBJECT(self->service)); self->service = NULL; } - g_hash_table_destroy(volume_states); + g_hash_table_destroy(volume_states); - free_the_animation_list(); + free_the_animation_list(); G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object); return; @@ -199,11 +199,11 @@ indicator_sound_dispose (GObject *object) static void free_the_animation_list() { - if(blocked_animation_list != NULL){ - g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); - g_list_free(blocked_animation_list); - blocked_animation_list = NULL; - } + if(blocked_animation_list != NULL){ + g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); + g_list_free(blocked_animation_list); + blocked_animation_list = NULL; + } } static void @@ -313,7 +313,19 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC static gboolean new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { g_debug("indicator-sound: new_transport_bar() called "); - TransportBar* bar = transport_bar_new(); + + GtkWidget* bar = NULL; + + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + + bar = transport_bar_new(); + GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent); + + gtk_widget_show_all(bar); + return TRUE; } @@ -387,34 +399,34 @@ Only called at startup. static void prepare_blocked_animation() { - gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); - gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)); + gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); + gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)); - GtkImage* temp_image = indicator_image_helper(muted_name); - GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image); + GtkImage* temp_image = indicator_image_helper(muted_name); + GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image); - temp_image = indicator_image_helper(blocked_name); - GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); + temp_image = indicator_image_helper(blocked_name); + GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); - if(mute_buf == NULL || blocked_buf == NULL){ - g_debug("Don bother with the animation, the theme aint got the goods !"); - return; - } + if(mute_buf == NULL || blocked_buf == NULL){ + g_debug("Don bother with the animation, the theme aint got the goods !"); + return; + } - int i; + int i; - // sample 51 snapshots - range : 0-256 - for(i = 0; i < 51; i++) - { - gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, - gdk_pixbuf_get_width(mute_buf), - gdk_pixbuf_get_height(mute_buf), - 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 5)); - blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); - } - g_object_ref_sink(mute_buf); + // sample 51 snapshots - range : 0-256 + for(i = 0; i < 51; i++) + { + gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0, + gdk_pixbuf_get_width(mute_buf), + gdk_pixbuf_get_height(mute_buf), + 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 5)); + blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); + } + g_object_ref_sink(mute_buf); g_object_unref(mute_buf); - g_object_ref_sink(blocked_buf); + g_object_ref_sink(blocked_buf); g_object_unref(blocked_buf); } @@ -422,26 +434,26 @@ prepare_blocked_animation() gint get_state() { - return current_state; + return current_state; } gchar* get_state_image_name(gint state) { - return g_hash_table_lookup(volume_states, GINT_TO_POINTER(state)); + return g_hash_table_lookup(volume_states, GINT_TO_POINTER(state)); } void prepare_for_tests(IndicatorObject *io) { - prepare_state_machine(); - get_icon(io); + prepare_state_machine(); + get_icon(io); } void tidy_up_hash() { - g_hash_table_destroy(volume_states); + g_hash_table_destroy(volume_states); } static void @@ -449,13 +461,13 @@ update_state(const gint state) { /* g_debug("update state beginning - previous_state = %i", previous_state);*/ - previous_state = current_state; + previous_state = current_state; /* g_debug("update state 3rd line - previous_state = %i", previous_state);*/ - current_state = state; - gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); - indicator_image_helper_update(speaker_image, image_name); + current_state = state; + gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); + indicator_image_helper_update(speaker_image, image_name); } diff --git a/src/transport-bar.c b/src/transport-bar.c index 8573cae..34f590e 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -30,7 +30,7 @@ typedef struct _TransportBarPrivate TransportBarPrivate; struct _TransportBarPrivate { - GtkWidget* hBox; + GtkWidget* hbox; GtkWidget* previous_button; GtkWidget* play_button; GtkWidget* next_button; @@ -43,7 +43,8 @@ static void transport_bar_class_init (TransportBarClass *klass); static void transport_bar_init (TransportBar *self); static void transport_bar_dispose (GObject *object); static void transport_bar_finalize (GObject *object); -G_DEFINE_TYPE (TransportBar, transport_bar, DBUSMENU_TYPE_MENUITEM); + +G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); static void transport_bar_class_init (TransportBarClass *klass) @@ -54,29 +55,35 @@ transport_bar_class_init (TransportBarClass *klass) object_class->dispose = transport_bar_dispose; object_class->finalize = transport_bar_finalize; - - return; } static void transport_bar_init (TransportBar *self) { - g_debug("Building new Transport Item"); - hBox = gtk_hbox_new(TRUE, 2)); - previous_button = gtk_button_new_with_label("Previous")); - next_button = gtk_button_new_with_label("Next")); - play_button = gtk_button_new_with_label("Play")); - gtk_container_add((GtkContainer*) hBox, previous_button); - gtk_container_add((GtkContainer*) hBox, next_button); - gtk_container_add((GtkContainer*) hBox, play_button); - return; + g_debug("TransportBar::transport_bar_init"); + + TransportBarPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(self); + GtkWidget *hbox; + + hbox = gtk_hbox_new(TRUE, 2); + priv->previous_button = gtk_button_new_with_label("Previous"); + priv->next_button = gtk_button_new_with_label("Next"); + priv->play_button = gtk_button_new_with_label("Play"); + + gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); + + priv->hbox = hbox; + + gtk_widget_show_all (priv->hbox); + gtk_container_add (GTK_CONTAINER (self), hbox); } static void transport_bar_dispose (GObject *object) { G_OBJECT_CLASS (transport_bar_parent_class)->dispose (object); - return; } static void @@ -85,9 +92,13 @@ transport_bar_finalize (GObject *object) G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object); } -TransportBar* +/** + * transport_new: + * @returns: a new #TransportBar. + **/ +GtkWidget* transport_bar_new() { - TransportBar *self = g_object_new(TRANSPORT_BAR_TYPE, NULL); - return self; + return g_object_new(TRANSPORT_BAR_TYPE, NULL); } + diff --git a/src/transport-bar.h b/src/transport-bar.h index e931298..e90e39c 100644 --- a/src/transport-bar.h +++ b/src/transport-bar.h @@ -19,8 +19,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef __TRANSPORT_BAR_H__ #define __TRANSPORT_BAR_H__ -#include <glib.h> -#include <glib-object.h> +#include <gtk/gtkmenuitem.h> G_BEGIN_DECLS @@ -35,13 +34,15 @@ typedef struct _TransportBar TransportBar; typedef struct _TransportBarClass TransportBarClass; struct _TransportBarClass { + GtkMenuItemClass parent_class; }; struct _TransportBar { + GtkMenuItem parent; }; GType transport_bar_get_type (void); -TransportBar* transport_bar_new(); +GtkWidget* transport_bar_new(); G_END_DECLS |