aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-06-10 16:04:06 +0100
committerConor Curran <conor.curran@canonical.com>2010-06-10 16:04:06 +0100
commit50497b6b375cb96b77ed1700f58b8b8991f4c1ae (patch)
treead92da3c8d047b515f4c8118096834061660d605
parentc98d1cd6c1f1bc875eae17d77680c8ce5d6acb5f (diff)
downloadayatana-indicator-sound-50497b6b375cb96b77ed1700f58b8b8991f4c1ae.tar.gz
ayatana-indicator-sound-50497b6b375cb96b77ed1700f58b8b8991f4c1ae.tar.bz2
ayatana-indicator-sound-50497b6b375cb96b77ed1700f58b8b8991f4c1ae.zip
working on some signals
-rw-r--r--src/player-controller.vala31
-rw-r--r--src/transport-bar.c73
2 files changed, 83 insertions, 21 deletions
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 9cdf527..86f0e0f 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -11,14 +11,20 @@ public class PlayerController : GLib.Object
public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active)
{
this.root_menu = root;
- this.name = format_client_name(client_name);
+ this.name = format_client_name(client_name.strip());
this.is_active = active;
this.custom_items = new ArrayList<Dbusmenu.Menuitem>();
- //Dbusmenu.Menuitem[];
self_construct();
}
- public void self_construct()
+ public void vanish()
+ {
+ foreach(Dbusmenu.Menuitem item in this.custom_items){
+ root_menu.child_delete(item);
+ }
+ }
+
+ private void self_construct()
{
Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem();
this.custom_items.add(client_item);
@@ -29,19 +35,16 @@ public class PlayerController : GLib.Object
root_menu.child_append(transport_item);
}
- public void vanish()
+ private static string format_client_name(string client_name)
{
- foreach(Dbusmenu.Menuitem item in this.custom_items){
- root_menu.child_delete(item);
+ string formatted = client_name;
+ //debug("PlayerController->format_client_name");
+ if(formatted.len() > 1){
+ formatted = client_name.up(1).concat(client_name.slice(1, client_name.len()));
+ debug("PlayerController->format_client_name - : %s", formatted);
}
+
+ return formatted;
}
- public static string format_client_name(string client_name)
- {
- debug("PlayerController->format_client_name");
- //string first_letter = client_name.slice(1);
- //debug("PlayerController->format_client_name - first_letter: %s", first_letter);
- return client_name;
- }
-
} \ No newline at end of file
diff --git a/src/transport-bar.c b/src/transport-bar.c
index bafd917..aa618d2 100644
--- a/src/transport-bar.c
+++ b/src/transport-bar.c
@@ -36,6 +36,16 @@ struct _TransportBarPrivate
GtkWidget* next_button;
};
+enum {
+ PLAY,
+ PAUSE,
+ NEXT,
+ PREVIOUS,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
#define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate))
/* Prototypes */
@@ -49,6 +59,9 @@ static gboolean transport_bar_button_press_event (GtkWidget *menuite
GdkEventButton *event);
static gboolean transport_bar_button_release_event (GtkWidget *menuitem,
GdkEventButton *event);
+static gboolean transport_bar_play_button_trigger (GtkWidget* widget,
+ GdkEventButton *event,
+ gpointer user_data);
G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM);
@@ -57,7 +70,6 @@ static void
transport_bar_class_init (TransportBarClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- //GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->button_press_event = transport_bar_button_press_event;
@@ -67,6 +79,39 @@ transport_bar_class_init (TransportBarClass *klass)
gobject_class->dispose = transport_bar_dispose;
gobject_class->finalize = transport_bar_finalize;
+
+ signals[PLAY] = g_signal_new ("play",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[PAUSE] = g_signal_new ("pause",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+
+ signals[NEXT] = g_signal_new ("next",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[PREVIOUS] = g_signal_new ("previous",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -85,12 +130,16 @@ transport_bar_init (TransportBar *self)
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);
+
+ g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_bar_play_button_trigger), NULL);
+
priv->hbox = hbox;
gtk_widget_show_all (priv->hbox);
- gtk_widget_set_sensitive(GTK_WIDGET(self), FALSE);
gtk_container_add (GTK_CONTAINER (self), hbox);
+
+
}
static void
@@ -110,19 +159,29 @@ static gboolean
transport_bar_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TransportBar::button_press_event");
- return TRUE;
+ g_debug("TransportBar::menu_press_event");
+ return FALSE;
}
static gboolean
transport_bar_button_release_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TransportBar::button_release_event");
- return TRUE;
+ g_debug("TransportBar::menu_release_event");
+ return FALSE;
+}
+
+/* Individual keyevents on the buttons */
+static gboolean
+transport_bar_play_button_trigger(GtkWidget* widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ g_debug("TransportBar::PLAY button_press_event");
+ return FALSE;
}
-/**
+ /**
* transport_new:
* @returns: a new #TransportBar.
**/