diff options
-rw-r--r-- | configure.ac | 57 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/indicator-sound.c | 56 | ||||
-rw-r--r-- | src/metadata-widget.c | 12 | ||||
-rw-r--r-- | src/metadata-widget.h | 6 | ||||
-rw-r--r-- | src/transport-widget.c | 40 | ||||
-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 |
9 files changed, 137 insertions, 53 deletions
diff --git a/configure.ac b/configure.ac index ab02d4e..0758182 100644 --- a/configure.ac +++ b/configure.ac @@ -24,10 +24,21 @@ AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) ########################### +# GTK+ version option +########################### + +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk], + [Which version of gtk to use for the indicator @<:@default=3@:>@])], + [], + [with_gtk=3]) + +########################### # Dependencies ########################### -GTK_REQUIRED_VERSION=2.12 +GTK_REQUIRED_VERSION=2.22 +GTK3_REQUIRED_VERSION=3.0 INDICATOR_REQUIRED_VERSION=0.3.19 DBUSMENUGTK_REQUIRED_VERSION=0.3.101 POLKIT_REQUIRED_VERSION=0.92 @@ -37,12 +48,22 @@ DBUSMENUGLIB_REQUIRED_VERSION=0.3.101 GIO_2_0_REQUIRED_VERSION=2.25.13 LIBNOTIFY_REQUIRED_VERSION=0.7.0 -PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION - indicator >= $INDICATOR_REQUIRED_VERSION - dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS - libnotify >= $LIBNOTIFY_REQUIRED_VERSION) - +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK3_REQUIRED_VERSION + indicator3 >= $INDICATOR_REQUIRED_VERSION + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS + libnotify >= $LIBNOTIFY_REQUIRED_VERSION) + ], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION + indicator >= $INDICATOR_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS + libnotify >= $LIBNOTIFY_REQUIRED_VERSION) + ], + [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] +) AC_SUBST(APPLET_CFLAGS) AC_SUBST(APPLET_LIBS) @@ -53,7 +74,7 @@ AC_SUBST(PULSEAUDIO_CFLAGS) AC_SUBST(PULSEAUDIO_LIBS) PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - indicator >= $INDICATOR_REQUIRED_VERSION + indicator3 >= $INDICATOR_REQUIRED_VERSION gee-1.0 gio-unix-2.0 libxml-2.0) @@ -81,13 +102,20 @@ AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all # Indicator Info ########################### -if test "x$with_localinstall" = "xyes"; then +AS_IF([test "x$with_localinstall" = "xyes"], + [ INDICATORDIR="${libdir}/indicators/2/" - INDICATORICONSDIR="${datadir}/indicator-applet/icons/" -else - INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator` - INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator` -fi + INDICATORICONSDIR="${datadir}/indicator-sound/icons/" + ], + [AS_IF([test "x$with_gtk" = "x2"], + [ + INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator` + INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator` + ], + [ + INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator3` + INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator3` + ])]) AC_SUBST(INDICATORDIR) AC_SUBST(INDICATORICONSDIR) @@ -160,4 +188,5 @@ AC_MSG_NOTICE([ SUS Indicator Configuration: Prefix: $prefix + GTK+: $with_gtk ]) 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/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-widget.c b/src/metadata-widget.c index f687d0c..5c1db2f 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -267,7 +267,7 @@ 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)); GtkStyle *style; style = gtk_widget_get_style (metadata); @@ -357,7 +357,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); @@ -659,10 +659,12 @@ metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, style = gtk_widget_get_style (widget); - cr = (cairo_t*) gdk_cairo_create (widget->window); + cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget)); - x = widget->allocation.x; - y = widget->allocation.y; + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y; // Draw player icon if (priv->icon_buf != NULL){ 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/transport-widget.c b/src/transport-widget.c index f05c4c1..f9b5319 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -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,20 +1222,22 @@ _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); + GtkAllocation allocation; + gtk_widget_get_allocation (button, &allocation); + cairo_translate (cr, allocation.x, allocation.y); - //g_debug("button x allocation = %i", button->allocation.x); - //g_debug("button y allocation = %i", button->allocation.y); + //g_debug("button x allocation = %i", allocation.x); + //g_debug("button y allocation = %i", allocation.y); GtkStyle *style; @@ -1795,6 +1805,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 |