aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Terry <michael.terry@canonical.com>2011-06-22 15:19:49 -0400
committerMichael Terry <michael.terry@canonical.com>2011-06-22 15:19:49 -0400
commit41416ba7f8944ac60a6c1d84409d05a2d9e4d787 (patch)
treeab8893a878c38e7f383df787ca148d2f105ed489 /src
parent808a7108ec6c8cca9423b25269c846b5c6e2461d (diff)
downloadayatana-indicator-sound-41416ba7f8944ac60a6c1d84409d05a2d9e4d787.tar.gz
ayatana-indicator-sound-41416ba7f8944ac60a6c1d84409d05a2d9e4d787.tar.bz2
ayatana-indicator-sound-41416ba7f8944ac60a6c1d84409d05a2d9e4d787.zip
port to gtk3
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/indicator-sound.c56
-rw-r--r--src/metadata-widget.c12
-rw-r--r--src/metadata-widget.h6
-rw-r--r--src/transport-widget.c40
-rw-r--r--src/transport-widget.h5
-rw-r--r--src/voip-input-widget.h5
-rw-r--r--src/volume-widget.h5
8 files changed, 94 insertions, 39 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/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