Skip to content

Commit

Permalink
Add 'next' signal
Browse files Browse the repository at this point in the history
In order to reset the 'love' status.

Signed-off-by: Felipe Contreras <[email protected]>
  • Loading branch information
felipec committed Jun 26, 2010
1 parent 9378d11 commit 1abf1f4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ metadata_callback(MafwRenderer *self,
sr_session_add_track(s->session, sr_track_dup(track));
sr_session_submit(s->session);
}
sr_service_next(dbus_service);
clear:
g_free(track->artist);
track->artist = NULL;
Expand Down
14 changes: 14 additions & 0 deletions service.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ static void *parent_class;

extern void scrobbler_love(gboolean on);

void
sr_service_next(struct sr_service *service)
{
struct sr_service_class *class;
class = g_type_class_peek(SR_SERVICE_TYPE);
g_signal_emit(G_OBJECT(service), class->next_sig, 0, service);
}

static gboolean
sr_service_love(struct sr_service *service, gboolean on)
{
Expand Down Expand Up @@ -46,6 +54,12 @@ class_init(void *g_class,

service_class->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
dbus_g_object_type_install_info(SR_SERVICE_TYPE, &dbus_glib_sr_service_object_info);

service_class->next_sig = g_signal_new("next", G_OBJECT_CLASS_TYPE(g_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}

GType
Expand Down
3 changes: 3 additions & 0 deletions service.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ struct sr_service {
struct sr_service_class {
GObjectClass parent_class;
void *connection;
guint next_sig;
};

#define SR_SERVICE_TYPE (sr_service_get_type())
#define SR_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SR_SERVICE_TYPE, struct sr_service))
#define SR_SERVICE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), SR_SERVICE_TYPE, struct sr_service_class))
#define SR_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SR_SERVICE_TYPE, struct sr_service_class))

void sr_service_next(struct sr_service *service);

GType sr_service_get_type(void);

#endif /* SR_SERVICE_H */
1 change: 1 addition & 0 deletions service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<method name="Love">
<arg type="b" name="on"/>
</method>
<signal name="Next"/>
</interface>
</node>
10 changes: 10 additions & 0 deletions widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ love_cb(GtkWidget *widget,
return TRUE;
}

static void
next_cb(DBusGProxy *proxy, gpointer user_data)
{
loved = 0;
gtk_widget_queue_draw(GTK_WIDGET(user_data));
}

static GtkWidget *
build_ui(struct sr_widget *widget)
{
Expand All @@ -47,6 +54,8 @@ instance_init(GTypeInstance *instance,
GtkWidget *contents = build_ui(SR_WIDGET(instance));
gtk_window_set_default_size(GTK_WINDOW(instance), 96, 96);
gtk_container_add(GTK_CONTAINER(instance), contents);

dbus_g_proxy_connect_signal(sr_service, "Next", G_CALLBACK(next_cb), instance, NULL);
}

static void *parent_class;
Expand Down Expand Up @@ -124,6 +133,7 @@ class_init(void *g_class,
"org.scrobbler.service",
"/org/scrobbler/service",
"org.scrobbler.service");
dbus_g_proxy_add_signal(sr_service, "Next", G_TYPE_INVALID, G_TYPE_INVALID);
dbus_g_connection_unref(bus);
}

Expand Down

0 comments on commit 1abf1f4

Please sign in to comment.