From 41416ba7f8944ac60a6c1d84409d05a2d9e4d787 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 22 Jun 2011 15:19:49 -0400 Subject: port to gtk3 --- src/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Makefile.am') 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 ";" >> $@ -- cgit v1.2.3 From 5f35f5e36e90e32aed5105434ee1ecae7c09806b Mon Sep 17 00:00:00 2001 From: "Marco Trevisan (Treviño)" Date: Sun, 17 Jul 2011 04:40:00 +0200 Subject: Added MuteWidget item to control the mute-menu-item remotely It's basically a GtkMenuItem that can be activated to change the mute status. --- src/Makefile.am | 2 + src/mute-widget.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mute-widget.h | 67 ++++++++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 src/mute-widget.c create mode 100644 src/mute-widget.h (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index e35f871..60c7249 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,8 @@ libsoundmenu_la_SOURCES = \ transport-widget.h \ metadata-widget.c \ metadata-widget.h \ + mute-widget.c \ + mute-widget.h \ volume-widget.c \ volume-widget.h \ voip-input-widget.c \ diff --git a/src/mute-widget.c b/src/mute-widget.c new file mode 100644 index 0000000..97c87ff --- /dev/null +++ b/src/mute-widget.c @@ -0,0 +1,141 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Marco Trevisan (Treviño) + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include "mute-widget.h" +#include "common-defs.h" +#include "indicator-sound.h" + +typedef struct _MuteWidgetPrivate MuteWidgetPrivate; + +struct _MuteWidgetPrivate +{ + DbusmenuMenuitem *item; + GtkMenuItem *gitem; +}; + +#define MUTE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MUTE_WIDGET_TYPE, MuteWidgetPrivate)) + +/* Prototypes */ +static void mute_widget_class_init (MuteWidgetClass *klass); +static void mute_widget_init (MuteWidget *self); +static void mute_widget_dispose (GObject *object); +static void mute_widget_finalize (GObject *object); + +G_DEFINE_TYPE (MuteWidget, mute_widget, G_TYPE_OBJECT); + +static void +mute_widget_class_init (MuteWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->dispose = mute_widget_dispose; + gobject_class->finalize = mute_widget_finalize; + g_type_class_add_private (klass, sizeof (MuteWidgetPrivate)); +} + +static void +mute_widget_init (MuteWidget *self) +{ + MuteWidgetPrivate *priv = MUTE_WIDGET_GET_PRIVATE(self); + priv->item = NULL; + priv->gitem = GTK_MENU_ITEM(gtk_menu_item_new ()); +} + +static void +mute_widget_dispose (GObject *object) +{ + G_OBJECT_CLASS (mute_widget_parent_class)->dispose (object); +} + +static void +mute_widget_finalize (GObject *object) +{ + MuteWidget *self = MUTE_WIDGET (object); + MuteWidgetPrivate *priv = MUTE_WIDGET_GET_PRIVATE(self); + + g_object_unref (priv->item); + g_object_unref (G_OBJECT (priv->gitem)); + G_OBJECT_CLASS (mute_widget_parent_class)->finalize (object); +} + +GtkMenuItem * +mute_widget_get_menu_item(MuteWidget *self) +{ + MuteWidgetPrivate *priv = MUTE_WIDGET_GET_PRIVATE(self); + return priv->gitem; +} + +MuteStatus +mute_widget_get_status (MuteWidget *self) +{ + g_return_val_if_fail(self, MUTE_STATUS_UNAVAILABLE); + MuteStatus status = MUTE_STATUS_UNAVAILABLE; + MuteWidgetPrivate *priv = MUTE_WIDGET_GET_PRIVATE(self); + + GVariant *vstatus = dbusmenu_menuitem_property_get_variant(priv->item, + DBUSMENU_MUTE_MENUITEM_VALUE); + + if (g_variant_is_of_type (vstatus, G_VARIANT_TYPE_BOOLEAN)) + { + if (g_variant_get_boolean (vstatus)) + status = MUTE_STATUS_MUTED; + else + status = MUTE_STATUS_UNMUTED; + } + + return status; +} + +void mute_widget_toggle (MuteWidget *self) +{ + g_return_if_fail (self); + MuteWidgetPrivate *priv = MUTE_WIDGET_GET_PRIVATE(self); + gtk_menu_item_activate (priv->gitem); +} + +/** + * mute_widget_new: + * @returns: a new #MuteWidget. + **/ +MuteWidget * +mute_widget_new (DbusmenuMenuitem *item) +{ + MuteWidget* widget = g_object_new(MUTE_WIDGET_TYPE, NULL); + MuteWidgetPrivate* priv = MUTE_WIDGET_GET_PRIVATE(widget); + priv->item = g_object_ref(item); + + GVariant *label = dbusmenu_menuitem_property_get_variant(priv->item, + DBUSMENU_MENUITEM_PROP_LABEL); + + if (g_variant_is_of_type(label, G_VARIANT_TYPE_STRING)) + gtk_menu_item_set_label(priv->gitem, g_variant_get_string(label, NULL)); + + if (label) + { + g_debug("Added a new Mute Widget %s", g_variant_print(label, FALSE)); + g_variant_unref(label); + } + + return widget; +} diff --git a/src/mute-widget.h b/src/mute-widget.h new file mode 100644 index 0000000..95130a1 --- /dev/null +++ b/src/mute-widget.h @@ -0,0 +1,67 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Marco Trevisan (Treviño) + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +#ifndef __MUTE_WIDGET_H__ +#define __MUTE_WIDGET_H__ + +#include +#include +#include +#if GTK_CHECK_VERSION(3, 0, 0) +#include +#else +#include +#endif +#include + +G_BEGIN_DECLS + +#define MUTE_WIDGET_TYPE (mute_widget_get_type ()) +#define MUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MUTE_WIDGET_TYPE, MuteWidget)) +#define MUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MUTE_WIDGET_TYPE, MuteWidgetClass)) +#define IS_MUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MUTE_WIDGET_TYPE)) +#define IS_MUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MUTE_WIDGET_TYPE)) +#define MUTE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MUTE_WIDGET_TYPE, MuteWidgetClass)) + +typedef struct _MuteWidget MuteWidget; +typedef struct _MuteWidgetClass MuteWidgetClass; + +struct _MuteWidgetClass { + GObjectClass parent_class; +}; + +struct _MuteWidget { + GObject parent; +}; + +typedef enum { + MUTE_STATUS_UNAVAILABLE, + MUTE_STATUS_MUTED, + MUTE_STATUS_UNMUTED +} MuteStatus; + +GType mute_widget_get_type (void) G_GNUC_CONST; +MuteWidget* mute_widget_new (DbusmenuMenuitem *item); +MuteStatus mute_widget_get_status (MuteWidget *self); +void mute_widget_toggle (MuteWidget *self); +GtkMenuItem *mute_widget_get_menu_item (MuteWidget *self); + +G_END_DECLS + +#endif + -- cgit v1.2.3 From 65982386494b0ffe4ff8bdf4be698e8b7616f561 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 29 Jul 2011 16:06:41 +0100 Subject: ifdefs needed for gtk2 compilation --- src/Makefile.am | 2 +- src/transport-widget.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index 60c7249..9c56c0e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -109,7 +109,7 @@ indicator_sound_service_SOURCES = \ gen-sound-service.xml.c \ $(music_bridge_VALASOURCES:.vala=.c) -indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall +indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) ######################### diff --git a/src/transport-widget.c b/src/transport-widget.c index 898472e..564b76f 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -87,9 +87,11 @@ struct _TransportWidgetPrivate gint skip_frequency; }; +#if GTK_CHECK_VERSION(3, 0, 0) static GList *transport_widget_list = NULL; static GtkStyleContext *spinner_style_context = NULL; static GtkWidgetPath *spinner_widget_path = NULL; +#endif // TODO refactor the UI handlers, consolidate functionality between key press /release // and button press / release. @@ -171,7 +173,7 @@ static void transport_widget_init (TransportWidget *self) { TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self); - + #if GTK_CHECK_VERSION(3, 0, 0) if (transport_widget_list == NULL){ /* append the object to the static linked list. */ transport_widget_list = g_list_append (transport_widget_list, self); @@ -188,7 +190,7 @@ transport_widget_init (TransportWidget *self) gtk_style_context_set_path (spinner_style_context, spinner_widget_path); gtk_style_context_add_class (spinner_style_context, GTK_STYLE_CLASS_SPINNER); } - + #endif priv->current_command = TRANSPORT_ACTION_NO_ACTION; priv->current_state = TRANSPORT_STATE_PAUSED; priv->key_event = TRANSPORT_ACTION_NO_ACTION; @@ -248,6 +250,7 @@ transport_widget_init (TransportWidget *self) static void transport_widget_dispose (GObject *object) { + #if GTK_CHECK_VERSION(3, 0, 0) transport_widget_list = g_list_remove (transport_widget_list, object); if (transport_widget_list == NULL){ @@ -261,7 +264,7 @@ transport_widget_dispose (GObject *object) spinner_style_context = NULL; } } - + #endif G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object); } @@ -280,7 +283,6 @@ transport_widget_expose (GtkWidget *button, GdkEventExpose *event) cairo_t *cr; 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, event->area.x, event->area.y, event->area.width, event->area.height); @@ -1791,10 +1793,13 @@ draw (GtkWidget* button, cairo_t *cr) FALSE); _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y); } + #if GTK_CHECK_VERSION(3, 0, 0) else if(priv->current_state == TRANSPORT_STATE_LAUNCHING) { + gtk_render_activity (spinner_style_context, cr, 106, 6 , 30, 30); } + #endif return FALSE; } @@ -1831,12 +1836,14 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, TransportState new_state = (TransportState)g_variant_get_int32(value); //g_debug("transport_widget_update_state - with value %i", new_state); if (new_state == TRANSPORT_STATE_LAUNCHING){ + #if GTK_CHECK_VERSION(3, 0, 0) gtk_style_context_notify_state_change (spinner_style_context, gtk_widget_get_window ( GTK_WIDGET(userdata)), NULL, GTK_STATE_FLAG_ACTIVE, TRUE); gtk_style_context_set_state (spinner_style_context, GTK_STATE_FLAG_ACTIVE); + #endif priv->current_state = TRANSPORT_STATE_LAUNCHING; g_debug("TransportWidget::toggle play state : %i", priv->current_state); -- cgit v1.2.3 From c60b7f972eb8faa1b06366dfebdb4a220d565f1e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 29 Jul 2011 17:18:02 +0100 Subject: bumped for release and removed -Werror from makefile.am until valac fixes its issues --- configure.ac | 4 ++-- src/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Makefile.am') diff --git a/configure.ac b/configure.ac index 47d8350..25f861a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.7.4, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.7.4.1, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.7.4) +AM_INIT_AUTOMAKE(indicator-sound, 0.7.4.1) AM_MAINTAINER_MODE diff --git a/src/Makefile.am b/src/Makefile.am index 9c56c0e..60c7249 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -109,7 +109,7 @@ indicator_sound_service_SOURCES = \ gen-sound-service.xml.c \ $(music_bridge_VALASOURCES:.vala=.c) -indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror +indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) ######################### -- cgit v1.2.3