diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-06-28 10:51:50 -0400 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-06-28 10:51:50 -0400 |
commit | fbe33a6d8e37468d5f01c5747c9ccb1763208db6 (patch) | |
tree | 91f441e199f5b319b30f21fbbe421323dc9bdc2a /src | |
parent | b004f06319c37e63adee52cff5a6258e900ad8a2 (diff) | |
parent | f11a6bb0c8bc68d0a6972e94140f7b5d96881dba (diff) | |
download | ayatana-indicator-sound-fbe33a6d8e37468d5f01c5747c9ccb1763208db6.tar.gz ayatana-indicator-sound-fbe33a6d8e37468d5f01c5747c9ccb1763208db6.tar.bz2 ayatana-indicator-sound-fbe33a6d8e37468d5f01c5747c9ccb1763208db6.zip |
Import upstream version 0.7.2
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/Makefile.in | 13 | ||||
-rw-r--r-- | src/fetch-file.c | 2 | ||||
-rw-r--r-- | src/freedesktop-interfaces.c | 2 | ||||
-rw-r--r-- | src/indicator-sound.c | 56 | ||||
-rw-r--r-- | src/metadata-menu-item.c | 2 | ||||
-rw-r--r-- | src/metadata-widget.c | 331 | ||||
-rw-r--r-- | src/metadata-widget.h | 6 | ||||
-rw-r--r-- | src/mpris2-controller.c | 2 | ||||
-rw-r--r-- | src/mpris2-interfaces.c | 2 | ||||
-rw-r--r-- | src/mpris2-watcher.c | 2 | ||||
-rw-r--r-- | src/music-player-bridge.c | 2 | ||||
-rw-r--r-- | src/music-player-bridge.h | 2 | ||||
-rw-r--r-- | src/player-controller.c | 2 | ||||
-rw-r--r-- | src/player-item.c | 2 | ||||
-rw-r--r-- | src/playlists-menu-item.c | 2 | ||||
-rw-r--r-- | src/settings-manager.c | 6 | ||||
-rw-r--r-- | src/transport-menu-item.c | 2 | ||||
-rw-r--r-- | src/transport-widget.c | 55 | ||||
-rw-r--r-- | src/transport-widget.h | 5 | ||||
-rw-r--r-- | src/voip-input-widget.h | 5 | ||||
-rw-r--r-- | src/volume-widget.h | 5 |
22 files changed, 377 insertions, 133 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index c546f0f..e35f871 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -118,11 +118,11 @@ DBUS_SPECS = \ gen-%.xml.h: %.xml @echo "Building $@ from $<" - @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@ + @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@ gen-%.xml.c: %.xml @echo "Building $@ from $<" - @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@ + @echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@ @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ @echo ";" >> $@ diff --git a/src/Makefile.in b/src/Makefile.in index d50e2b5..6ffa65e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -39,7 +39,10 @@ libexec_PROGRAMS = indicator-sound-service$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/intltool.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -176,6 +179,7 @@ DATADIRNAME = @DATADIRNAME@ DBUSSERVICEDIR = @DBUSSERVICEDIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -219,6 +223,7 @@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ @@ -262,6 +267,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -295,7 +301,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -1238,11 +1243,11 @@ music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES) gen-%.xml.h: %.xml @echo "Building $@ from $<" - @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@ + @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@ gen-%.xml.c: %.xml @echo "Building $@ from $<" - @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@ + @echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@ @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ @echo ";" >> $@ diff --git a/src/fetch-file.c b/src/fetch-file.c index 91af817..401c53f 100644 --- a/src/fetch-file.c +++ b/src/fetch-file.c @@ -1,4 +1,4 @@ -/* fetch-file.c generated by valac 0.12.0, the Vala compiler +/* fetch-file.c generated by valac 0.12.1, the Vala compiler * generated from fetch-file.vala, do not modify */ /* diff --git a/src/freedesktop-interfaces.c b/src/freedesktop-interfaces.c index c8f4c39..287c3e0 100644 --- a/src/freedesktop-interfaces.c +++ b/src/freedesktop-interfaces.c @@ -1,4 +1,4 @@ -/* freedesktop-interfaces.c generated by valac 0.12.0, the Vala compiler +/* freedesktop-interfaces.c generated by valac 0.12.1, the Vala compiler * generated from freedesktop-interfaces.vala, do not modify */ /* diff --git a/src/indicator-sound.c b/src/indicator-sound.c index f2ec0a2..b8c0351 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -23,7 +23,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib/gi18n.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menu.h> +#else #include <libdbusmenu-gtk/menu.h> +#endif #include <libido/idoscalemenuitem.h> #include <gio/gio.h> @@ -459,6 +463,26 @@ new_voip_slider_widget (DbusmenuMenuitem * newitem, //UI callbacks /******************************************************************/ +static GtkWidget * +get_current_item (GtkContainer * container) +{ + GList *children = gtk_container_get_children (container); + GList *iter; + GtkWidget *rv = NULL; + + /* Suprisingly, GTK+ doesn't really let us query "what is the currently + selected item?". But it does note it internally by prelighting the + widget, so we watch for that. */ + for (iter = children; iter; iter = iter->next) { + if (gtk_widget_get_state (GTK_WIDGET (iter->data)) & GTK_STATE_PRELIGHT) { + rv = GTK_WIDGET (iter->data); + break; + } + } + + return rv; +} + /** key_press_cb: **/ @@ -473,7 +497,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator); GtkWidget *menuitem; - menuitem = GTK_MENU_SHELL (widget)->active_menu_item; + menuitem = get_current_item (GTK_CONTAINER (widget)); if (IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE){ gdouble current_value = 0; @@ -502,19 +526,19 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) } switch (event->keyval) { - case GDK_Right: + case GDK_KEY_Right: digested = TRUE; new_value = current_value + five_percent; break; - case GDK_Left: + case GDK_KEY_Left: digested = TRUE; new_value = current_value - five_percent; break; - case GDK_plus: + case GDK_KEY_plus: digested = TRUE; new_value = current_value + five_percent; break; - case GDK_minus: + case GDK_KEY_minus: digested = TRUE; new_value = current_value - five_percent; break; @@ -542,12 +566,12 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) } switch (event->keyval) { - case GDK_Right: + case GDK_KEY_Right: transport_widget_react_to_key_press_event ( transport_widget, TRANSPORT_ACTION_NEXT ); digested = TRUE; break; - case GDK_Left: + case GDK_KEY_Left: transport_widget_react_to_key_press_event ( transport_widget, TRANSPORT_ACTION_PREVIOUS ); digested = TRUE; @@ -557,8 +581,8 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) TRANSPORT_ACTION_PLAY_PAUSE ); digested = TRUE; break; - case GDK_Up: - case GDK_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: digested = FALSE; break; default: @@ -585,7 +609,7 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) GtkWidget *menuitem; - menuitem = GTK_MENU_SHELL (widget)->active_menu_item; + menuitem = get_current_item (GTK_CONTAINER (widget)); if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { TransportWidget* transport_widget = NULL; GList* elem; @@ -597,12 +621,12 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) } switch (event->keyval) { - case GDK_Right: + case GDK_KEY_Right: transport_widget_react_to_key_release_event ( transport_widget, TRANSPORT_ACTION_NEXT ); digested = TRUE; break; - case GDK_Left: + case GDK_KEY_Left: transport_widget_react_to_key_release_event ( transport_widget, TRANSPORT_ACTION_PREVIOUS ); digested = TRUE; @@ -612,8 +636,8 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) TRANSPORT_ACTION_PLAY_PAUSE ); digested = TRUE; break; - case GDK_Up: - case GDK_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: digested = FALSE; break; default: @@ -643,9 +667,9 @@ indicator_sound_scroll (IndicatorObject *io, gint delta, GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider)); //g_debug("indicator-sound-scroll - current slider value %f", value); if (direction == INDICATOR_OBJECT_SCROLL_UP) { - value += adj->step_increment; + value += gtk_adjustment_get_step_increment (adj); } else { - value -= adj->step_increment; + value -= gtk_adjustment_get_step_increment (adj); } //g_debug("indicator-sound-scroll - update slider with value %f", value); volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value, "scroll updates"); diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c index 4344945..56c0c8c 100644 --- a/src/metadata-menu-item.c +++ b/src/metadata-menu-item.c @@ -1,4 +1,4 @@ -/* metadata-menu-item.c generated by valac 0.12.0, the Vala compiler +/* metadata-menu-item.c generated by valac 0.12.1, the Vala compiler * generated from metadata-menu-item.vala, do not modify */ /* diff --git a/src/metadata-widget.c b/src/metadata-widget.c index f687d0c..d522358 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -46,6 +46,7 @@ struct _MetadataWidgetPrivate GtkWidget* player_label; GdkPixbuf* icon_buf; DbusmenuMenuitem* twin_item; + gint current_height; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -55,12 +56,16 @@ static void metadata_widget_class_init (MetadataWidgetClass *klass); static void metadata_widget_init (MetadataWidget *self); static void metadata_widget_dispose (GObject *object); static void metadata_widget_finalize (GObject *object); -static gboolean metadata_image_expose (GtkWidget *image, - GdkEventExpose *event, - gpointer user_data); static void metadata_widget_set_style (GtkWidget* button, GtkStyle* style); static void metadata_widget_set_twin_item (MetadataWidget* self, DbusmenuMenuitem* twin_item); +static void metadata_get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width); +static void metadata_get_preferred_height (GtkWidget *widget, + gint *minimal_width, + gint *natural_width); + // keyevent consumers static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, @@ -72,15 +77,29 @@ static void metadata_widget_property_update (DbusmenuMenuitem* item, gpointer userdata); static void metadata_widget_style_labels ( MetadataWidget* self, GtkLabel* label); -static void draw_album_art_placeholder ( GtkWidget *metadata); -static void draw_album_border ( GtkWidget *metadata, gboolean selected); +static void draw_album_art_placeholder (GtkWidget *metadata); + +static void draw_album_border (GtkWidget *metadata, gboolean selected); static void metadata_widget_selection_received_event_callback( GtkWidget *widget, GtkSelectionData *data, guint time, gpointer user_data); -static gboolean metadata_widget_icon_triangle_draw_cb ( GtkWidget *image, - GdkEventExpose *event, - gpointer user_data ); + +#if GTK_CHECK_VERSION(3, 0, 0) +static gboolean metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *image, + cairo_t* cr, + gpointer user_data); +static gboolean metadata_image_expose_gtk_3 (GtkWidget *image, + cairo_t* cr, + gpointer user_data); +#else +static gboolean metadata_widget_icon_triangle_draw_cb (GtkWidget *image, + GdkEventExpose *event, + gpointer user_data); +static gboolean metadata_image_expose (GtkWidget *image, + GdkEventExpose *event, + gpointer user_data); +#endif static void metadata_widget_set_icon (MetadataWidget *self); static void metadata_widget_handle_resizing (MetadataWidget* self); @@ -96,13 +115,35 @@ metadata_widget_class_init (MetadataWidgetClass *klass) widget_class->button_release_event = metadata_widget_button_release_event; + #if GTK_CHECK_VERSION(3, 0, 0) + widget_class->get_preferred_width = metadata_get_preferred_width; + widget_class->get_preferred_height = metadata_get_preferred_height; + #endif g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate)); gobject_class->dispose = metadata_widget_dispose; gobject_class->finalize = metadata_widget_finalize; } +#if GTK_CHECK_VERSION(3, 0, 0) +static void +metadata_get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width) +{ + *minimal_width = *natural_width = 200; +} +static void +metadata_get_preferred_height (GtkWidget *widget, + gint *minimal_height, + gint *natural_height) +{ + //MetadataWidget* self = METADATA_WIDGET (widget); + //MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + *minimal_height = *natural_height = 95;//priv->current_height; +} +#endif static void metadata_widget_init (MetadataWidget *self) @@ -116,20 +157,30 @@ metadata_widget_init (MetadataWidget *self) hbox = gtk_hbox_new(FALSE, 0); priv->meta_data_h_box = hbox; - + priv->current_height = 1; + // image priv->album_art = gtk_image_new(); priv->image_path = g_string_new(""); priv->old_image_path = g_string_new(""); + #if GTK_CHECK_VERSION(3, 0, 0) + g_signal_connect(priv->album_art, "draw", + G_CALLBACK(metadata_image_expose_gtk_3), + GTK_WIDGET(self)); + + g_signal_connect_after (GTK_WIDGET(self), "draw", + G_CALLBACK(metadata_widget_icon_triangle_draw_cb_gtk_3), + GTK_WIDGET(self)); + #else g_signal_connect(priv->album_art, "expose-event", G_CALLBACK(metadata_image_expose), GTK_WIDGET(self)); g_signal_connect_after (GTK_WIDGET(self), "expose-event", G_CALLBACK(metadata_widget_icon_triangle_draw_cb), - GTK_WIDGET(self)); - + GTK_WIDGET(self)); + #endif gtk_box_pack_start (GTK_BOX (priv->meta_data_h_box), priv->album_art, FALSE, @@ -189,9 +240,14 @@ metadata_widget_init (MetadataWidget *self) priv->player_label = player_label; gtk_box_pack_start (GTK_BOX(outer_v_box), priv->player_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (self), outer_v_box); + + gtk_widget_show_all (priv->meta_data_h_box); + gtk_widget_set_no_show_all (priv->meta_data_h_box, TRUE); + gtk_widget_hide (priv->meta_data_h_box); } static void @@ -211,13 +267,122 @@ metadata_widget_finalize (GObject *object) G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); } - /** * We override the expose method to enable primitive drawing of the * empty album art image and rounded rectangles on the album art. */ + +#if GTK_CHECK_VERSION(3, 0, 0) static gboolean -metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user_data) +metadata_image_expose_gtk_3 (GtkWidget *metadata, + cairo_t* cr, + gpointer user_data) +{ + g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + MetadataWidget* widget = METADATA_WIDGET(user_data); + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); + + if ( TRUE == dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(priv->twin_item), + DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS)) + { + return FALSE; + } + + draw_album_border (metadata, FALSE); + + if(priv->image_path->len > 0){ + if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || + priv->theme_change_occured == TRUE){ + priv->theme_change_occured = FALSE; + GdkPixbuf* pixbuf; + pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL); + + if(GDK_IS_PIXBUF(pixbuf) == FALSE){ + gtk_image_clear ( GTK_IMAGE(priv->album_art)); + gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); + draw_album_art_placeholder(metadata); + return FALSE; + } + + gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); + gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), + gdk_pixbuf_get_width(pixbuf), + gdk_pixbuf_get_height(pixbuf)); + + g_string_erase (priv->old_image_path, 0, -1); + g_string_overwrite (priv->old_image_path, 0, priv->image_path->str); + g_object_unref(pixbuf); + } + return FALSE; + } + gtk_image_clear (GTK_IMAGE(priv->album_art)); + gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); + draw_album_art_placeholder(metadata); + return FALSE; +} + +// Draw the triangle if the player is running ... +static gboolean +metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget, + cairo_t* cr, + gpointer user_data) +{ + + g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + MetadataWidget* meta = METADATA_WIDGET(user_data); + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); + + GtkStyle *style; + int x, y, arrow_width, arrow_height; + + gint offset = 3; + arrow_width = 5; + arrow_height = 9; + + style = gtk_widget_get_style (widget); + + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = 0; + + // Draw player icon + if (priv->icon_buf != NULL){ + gdk_cairo_set_source_pixbuf (cr, + priv->icon_buf, + x + arrow_width + 1, + y + offset); + cairo_paint (cr); + } + + // Draw triangle but only if the player is running. + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ + y += (double)arrow_height/2.0 + offset; + cairo_set_line_width (cr, 1.0); + + //g_debug ("triangle drawing"); + + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + } + + return FALSE; +} + +// GTK 2 Expose handler +#else + +static gboolean +metadata_image_expose (GtkWidget *metadata, + GdkEventExpose *event, + gpointer user_data) { g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* widget = METADATA_WIDGET(user_data); @@ -252,7 +417,6 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user g_string_erase (priv->old_image_path, 0, -1); g_string_overwrite (priv->old_image_path, 0, priv->image_path->str); - g_object_unref(pixbuf); } return FALSE; @@ -263,11 +427,74 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user return FALSE; } + +// Draw the triangle if the player is running ... +static gboolean +metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, + GdkEventExpose *event, + gpointer user_data) +{ + g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + MetadataWidget* meta = METADATA_WIDGET(user_data); + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); + + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + gint offset = 3; + arrow_width = 5; + arrow_height = 9; + + style = gtk_widget_get_style (widget); + + cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget)); + + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y; + + // Draw player icon + if (priv->icon_buf != NULL){ + gdk_cairo_set_source_pixbuf (cr, + priv->icon_buf, + x + arrow_width + 1, + y + offset); + cairo_paint (cr); + } + + // Draw triangle but only if the player is running. + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ + y += (double)arrow_height/2.0 + offset; + cairo_set_line_width (cr, 1.0); + + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + } + + cairo_destroy (cr); + return FALSE; +} +#endif + static void draw_album_border(GtkWidget *metadata, gboolean selected) { cairo_t *cr; - cr = gdk_cairo_create (metadata->window); + cr = gdk_cairo_create (gtk_widget_get_window (metadata)); + #if GTK_CHECK_VERSION(3, 0, 0) + gtk_style_context_add_class (gtk_widget_get_style_context (metadata), + "menu"); + #endif + GtkStyle *style; style = gtk_widget_get_style (metadata); @@ -357,7 +584,7 @@ static void draw_album_art_placeholder(GtkWidget *metadata) { cairo_t *cr; - cr = gdk_cairo_create (metadata->window); + cr = gdk_cairo_create (gtk_widget_get_window (metadata)); GtkStyle *style; style = gtk_widget_get_style (metadata); @@ -507,25 +734,33 @@ metadata_widget_handle_resizing (MetadataWidget* self) { MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + g_debug ("SHOW/HIDE TRACK DETAILS - %i", dbusmenu_menuitem_property_get_bool (priv->twin_item, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS)); + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS) == TRUE){ + // TODO + // revert to hide + #if GTK_CHECK_VERSION(3, 0, 0) + gtk_widget_show (priv->meta_data_h_box); + #else gtk_widget_hide (priv->meta_data_h_box); gtk_widget_hide (priv->artist_label); gtk_widget_hide (priv->piece_label); gtk_widget_hide (priv->container_label); gtk_widget_hide (priv->album_art); - gtk_widget_hide (priv->meta_data_v_box); - gtk_widget_set_size_request(GTK_WIDGET(self), 200, 20); + gtk_widget_hide (priv->meta_data_v_box); + #endif } else{ - + #if GTK_CHECK_VERSION(3, 0, 0) + gtk_widget_show (priv->meta_data_h_box); + #else gtk_widget_show (priv->meta_data_h_box); gtk_widget_show (priv->artist_label); gtk_widget_show (priv->piece_label); gtk_widget_show (priv->container_label); gtk_widget_show (priv->album_art); - gtk_widget_show (priv->meta_data_v_box); - gtk_widget_set_size_request(GTK_WIDGET(self), 200, 95); + #endif } gtk_widget_queue_draw(GTK_WIDGET(self)); } @@ -639,60 +874,6 @@ metadata_widget_set_twin_item (MetadataWidget* self, metadata_widget_handle_resizing (self); } -// Draw the triangle if the player is running ... -static gboolean -metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, - GdkEventExpose *event, - gpointer user_data) -{ - g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); - MetadataWidget* meta = METADATA_WIDGET(user_data); - MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); - - GtkStyle *style; - cairo_t *cr; - int x, y, arrow_width, arrow_height; - - gint offset = 3; - arrow_width = 5; - arrow_height = 9; - - style = gtk_widget_get_style (widget); - - cr = (cairo_t*) gdk_cairo_create (widget->window); - - x = widget->allocation.x; - y = widget->allocation.y; - - // Draw player icon - if (priv->icon_buf != NULL){ - gdk_cairo_set_source_pixbuf (cr, - priv->icon_buf, - x + arrow_width + 1, - y + offset); - cairo_paint (cr); - } - - // Draw triangle but only if the player is running. - if (dbusmenu_menuitem_property_get_bool (priv->twin_item, - DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ - y += (double)arrow_height/2.0 + offset; - cairo_set_line_width (cr, 1.0); - - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + arrow_height); - cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); - cairo_close_path (cr); - cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, - style->fg[gtk_widget_get_state(widget)].green/65535.0, - style->fg[gtk_widget_get_state(widget)].blue/65535.0); - cairo_fill (cr); - } - - cairo_destroy (cr); - return FALSE; -} - /** * transport_new: * @returns: a new #MetadataWidget. diff --git a/src/metadata-widget.h b/src/metadata-widget.h index 30b629c..b0123a3 100644 --- a/src/metadata-widget.h +++ b/src/metadata-widget.h @@ -19,8 +19,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef __METADATA_WIDGET_H__ #define __METADATA_WIDGET_H__ -#include <gtk/gtkmenuitem.h> +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menuitem.h> +#else #include <libdbusmenu-gtk/menuitem.h> +#endif G_BEGIN_DECLS diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c index 64381ad..0905795 100644 --- a/src/mpris2-controller.c +++ b/src/mpris2-controller.c @@ -1,4 +1,4 @@ -/* mpris2-controller.c generated by valac 0.12.0, the Vala compiler +/* mpris2-controller.c generated by valac 0.12.1, the Vala compiler * generated from mpris2-controller.vala, do not modify */ /* diff --git a/src/mpris2-interfaces.c b/src/mpris2-interfaces.c index d6e38ca..b288a8f 100644 --- a/src/mpris2-interfaces.c +++ b/src/mpris2-interfaces.c @@ -1,4 +1,4 @@ -/* mpris2-interfaces.c generated by valac 0.12.0, the Vala compiler +/* mpris2-interfaces.c generated by valac 0.12.1, the Vala compiler * generated from mpris2-interfaces.vala, do not modify */ /* diff --git a/src/mpris2-watcher.c b/src/mpris2-watcher.c index d9cea7e..3b4c72d 100644 --- a/src/mpris2-watcher.c +++ b/src/mpris2-watcher.c @@ -1,4 +1,4 @@ -/* mpris2-watcher.c generated by valac 0.12.0, the Vala compiler +/* mpris2-watcher.c generated by valac 0.12.1, the Vala compiler * generated from mpris2-watcher.vala, do not modify */ /* diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c index e9c688b..852acd5 100644 --- a/src/music-player-bridge.c +++ b/src/music-player-bridge.c @@ -1,4 +1,4 @@ -/* music-player-bridge.c generated by valac 0.12.0, the Vala compiler +/* music-player-bridge.c generated by valac 0.12.1, the Vala compiler * generated from music-player-bridge.vala, do not modify */ /* diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h index d644c9c..7b7bcd8 100644 --- a/src/music-player-bridge.h +++ b/src/music-player-bridge.h @@ -1,4 +1,4 @@ -/* music-player-bridge.h generated by valac 0.12.0, the Vala compiler, do not modify */ +/* music-player-bridge.h generated by valac 0.12.1, the Vala compiler, do not modify */ #ifndef __MUSIC_PLAYER_BRIDGE_H__ diff --git a/src/player-controller.c b/src/player-controller.c index e2e2043..0510150 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -1,4 +1,4 @@ -/* player-controller.c generated by valac 0.12.0, the Vala compiler +/* player-controller.c generated by valac 0.12.1, the Vala compiler * generated from player-controller.vala, do not modify */ /* diff --git a/src/player-item.c b/src/player-item.c index cf9e806..3c9cbeb 100644 --- a/src/player-item.c +++ b/src/player-item.c @@ -1,4 +1,4 @@ -/* player-item.c generated by valac 0.12.0, the Vala compiler +/* player-item.c generated by valac 0.12.1, the Vala compiler * generated from player-item.vala, do not modify */ /* diff --git a/src/playlists-menu-item.c b/src/playlists-menu-item.c index 23d115e..c87dab1 100644 --- a/src/playlists-menu-item.c +++ b/src/playlists-menu-item.c @@ -1,4 +1,4 @@ -/* playlists-menu-item.c generated by valac 0.12.0, the Vala compiler +/* playlists-menu-item.c generated by valac 0.12.1, the Vala compiler * generated from playlists-menu-item.vala, do not modify */ /* diff --git a/src/settings-manager.c b/src/settings-manager.c index d433cb4..748cffe 100644 --- a/src/settings-manager.c +++ b/src/settings-manager.c @@ -1,4 +1,4 @@ -/* settings-manager.c generated by valac 0.12.0, the Vala compiler +/* settings-manager.c generated by valac 0.12.1, the Vala compiler * generated from settings-manager.vala, do not modify */ /* @@ -100,7 +100,9 @@ gchar** settings_manager_fetch_blacklist (SettingsManager* self, int* result_len g_return_val_if_fail (self != NULL, NULL); _tmp1_ = _tmp0_ = g_settings_get_strv (self->priv->settings, "blacklisted-media-players"); _tmp2_ = _tmp1_; - *result_length1 = _vala_array_length (_tmp0_); + if (result_length1) { + *result_length1 = _vala_array_length (_tmp0_); + } result = _tmp2_; return result; } diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c index 1a647a5..2f2fe0f 100644 --- a/src/transport-menu-item.c +++ b/src/transport-menu-item.c @@ -1,4 +1,4 @@ -/* transport-menu-item.c generated by valac 0.12.0, the Vala compiler +/* transport-menu-item.c generated by valac 0.12.1, the Vala compiler * generated from transport-menu-item.vala, do not modify */ /* diff --git a/src/transport-widget.c b/src/transport-widget.c index f05c4c1..11e0f91 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -31,7 +31,7 @@ Uses code from ctk #define RECT_WIDTH 130.0f #define Y 7.0f -#define X 80.0f +#define X 70.0f #define INNER_RADIUS 12.5 #define MIDDLE_RADIUS 13.0f #define OUTER_RADIUS 14.5f @@ -43,16 +43,16 @@ Uses code from ctk #define TRI_WIDTH 11.0f #define TRI_HEIGHT 13.0f #define TRI_OFFSET 6.0f -#define PREV_X 78.0f +#define PREV_X 68.0f #define PREV_Y 13.0f -#define NEXT_X 156.0f +#define NEXT_X 146.0f #define NEXT_Y 13.0f //prev_y #define PAUSE_WIDTH 21.0f #define PAUSE_HEIGHT 27.0f #define BAR_WIDTH 4.5f #define BAR_HEIGHT 24.0f #define BAR_OFFSET 10.0f -#define PAUSE_X 121.0f +#define PAUSE_X 111.0f #define PAUSE_Y 7.0f #define PLAY_WIDTH 28.0f #define PLAY_HEIGHT 29.0f @@ -104,8 +104,10 @@ G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM); /* essentials */ static void transport_widget_set_twin_item ( TransportWidget* self, DbusmenuMenuitem* twin_item); +#if ! GTK_CHECK_VERSION(3, 0, 0) static gboolean transport_widget_expose ( GtkWidget *button, GdkEventExpose *event); -static void draw (GtkWidget* button, cairo_t *cr); +#endif +static gboolean draw (GtkWidget* button, cairo_t *cr); /* UI and dbusmenu callbacks */ static gboolean transport_widget_button_press_event (GtkWidget *menuitem, @@ -133,8 +135,8 @@ static void transport_widget_react_to_button_release ( TransportWidget* button, TransportAction command); static void transport_widget_toggle_play_pause ( TransportWidget* button, TransportState update); -static void transport_widget_select (GtkItem* menu, gpointer Userdata); -static void transport_widget_deselect (GtkItem* menu, gpointer Userdata); +static void transport_widget_select (GtkWidget* menu, gpointer Userdata); +static void transport_widget_deselect (GtkWidget* menu, gpointer Userdata); static TransportAction transport_widget_collision_detection (gint x, gint y); static void transport_widget_start_timing (TransportWidget* widget); static gboolean transport_widget_trigger_seek (gpointer userdata); @@ -155,7 +157,11 @@ transport_widget_class_init (TransportWidgetClass *klass) widget_class->button_release_event = transport_widget_button_release_event; widget_class->motion_notify_event = transport_widget_motion_notify_event; widget_class->leave_notify_event = transport_widget_leave_notify_event; +#if GTK_CHECK_VERSION(3, 0, 0) + widget_class->draw = draw; +#else widget_class->expose_event = transport_widget_expose; +#endif gobject_class->dispose = transport_widget_dispose; gobject_class->finalize = transport_widget_finalize; @@ -212,11 +218,11 @@ transport_widget_init (TransportWidget *self) "notify", G_CALLBACK (transport_widget_notify), NULL); - g_signal_connect (GTK_ITEM(self), + g_signal_connect (G_OBJECT(self), "select", G_CALLBACK (transport_widget_select), NULL); - g_signal_connect (GTK_ITEM(self), + g_signal_connect (G_OBJECT(self), "deselect", G_CALLBACK (transport_widget_deselect), NULL); @@ -236,11 +242,12 @@ transport_widget_finalize (GObject *object) G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object); } +#if ! GTK_CHECK_VERSION(3, 0, 0) static gboolean transport_widget_expose (GtkWidget *button, GdkEventExpose *event) { cairo_t *cr; - cr = gdk_cairo_create (button->window); + cr = gdk_cairo_create (gtk_widget_get_window (button)); //g_debug("In the playbutton's expose method, x = %i, y=%i and width: %i and height: %i'"); cairo_rectangle (cr, @@ -253,6 +260,7 @@ transport_widget_expose (GtkWidget *button, GdkEventExpose *event) cairo_destroy (cr); return FALSE; } +#endif gboolean transport_widget_is_selected ( TransportWidget* widget ) @@ -434,7 +442,7 @@ transport_widget_button_release_event (GtkWidget *menuitem, } static void -transport_widget_select (GtkItem* item, gpointer Userdata) +transport_widget_select (GtkWidget* item, gpointer Userdata) { TransportWidget* transport = TRANSPORT_WIDGET(item); TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport ); @@ -442,7 +450,7 @@ transport_widget_select (GtkItem* item, gpointer Userdata) } static void -transport_widget_deselect (GtkItem* item, gpointer Userdata) +transport_widget_deselect (GtkWidget* item, gpointer Userdata) { TransportWidget* transport = TRANSPORT_WIDGET(item); TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport ); @@ -1214,23 +1222,28 @@ _surface_blur (cairo_surface_t* surface, cairo_surface_mark_dirty (surface); } -static void +static gboolean draw (GtkWidget* button, cairo_t *cr) { - g_return_if_fail(IS_TRANSPORT_WIDGET(button)); - g_return_if_fail( cr != NULL ); + g_return_val_if_fail(IS_TRANSPORT_WIDGET(button), FALSE); + g_return_val_if_fail(cr != NULL, FALSE); TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button); cairo_surface_t* surf = NULL; cairo_t* cr_surf = NULL; - cairo_translate (cr, button->allocation.x, button->allocation.y); - - //g_debug("button x allocation = %i", button->allocation.x); - //g_debug("button y allocation = %i", button->allocation.y); +#if ! GTK_CHECK_VERSION(3, 0, 0) + GtkAllocation allocation; + gtk_widget_get_allocation (button, &allocation); + cairo_translate (cr, allocation.x, allocation.y); +#endif GtkStyle *style; - + +#if GTK_CHECK_VERSION(3, 0, 0) + gtk_style_context_add_class (gtk_widget_get_style_context (button), + "menu"); +#endif CairoColorRGB bg_color, fg_color, bg_selected, bg_prelight; CairoColorRGB color_middle[2], color_middle_prelight[2], color_outer[2], color_outer_prelight[2], color_play_outer[2], color_play_outer_prelight[2], @@ -1795,6 +1808,8 @@ draw (GtkWidget* button, cairo_t *cr) FALSE); _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y); } + + return FALSE; } static void diff --git a/src/transport-widget.h b/src/transport-widget.h index e5e91dc..8c2ce48 100644 --- a/src/transport-widget.h +++ b/src/transport-widget.h @@ -20,8 +20,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define __TRANSPORT_WIDGET_H__ #include <gtk/gtk.h> -#include <gtk/gtkmenuitem.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menuitem.h> +#else #include <libdbusmenu-gtk/menuitem.h> +#endif #include "common-defs.h" diff --git a/src/voip-input-widget.h b/src/voip-input-widget.h index 29912f0..0e90665 100644 --- a/src/voip-input-widget.h +++ b/src/voip-input-widget.h @@ -21,7 +21,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> #include <glib-object.h> +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menuitem.h> +#else #include <libdbusmenu-gtk/menuitem.h> +#endif G_BEGIN_DECLS diff --git a/src/volume-widget.h b/src/volume-widget.h index 7012473..3deb99c 100644 --- a/src/volume-widget.h +++ b/src/volume-widget.h @@ -21,7 +21,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> #include <glib-object.h> +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menuitem.h> +#else #include <libdbusmenu-gtk/menuitem.h> +#endif #include <libindicator/indicator-object.h> G_BEGIN_DECLS |