~ubuntu-branches/ubuntu/utopic/rhythmbox/utopic-proposed

« back to all changes in this revision

Viewing changes to remote/dbus/rb-client.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2014-04-03 17:23:01 UTC
  • mfrom: (1.3.5)
  • Revision ID: package-import@ubuntu.com-20140403172301-1fd16h8r1nr8ytno
Tags: 3.0.2-0ubuntu1
* New upstream bugfix version (lp: #1296334)
* Clean patches included in the update
* debian/librhythmbox-core8.symbols:
  - new version update

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
 
81
81
static gchar **other_stuff = NULL;
82
82
 
 
83
static GMainLoop *mainloop = NULL;
 
84
 
83
85
static GOptionEntry args[] = {
84
86
        { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, NULL, NULL },
85
87
 
548
550
        g_hash_table_destroy (properties);
549
551
}
550
552
 
551
 
static void
552
 
state_changed_cb (GActionGroup *action, const char *action_name, GVariant *state, GMainLoop *loop)
553
 
{
554
 
        if (g_strcmp0 (action_name, "load-uri") == 0) {
555
 
                gboolean loaded, scanned;
556
 
 
557
 
                g_variant_get (state, "(bb)", &loaded, &scanned);
558
 
                if (loaded && scanned) {
559
 
                        /* give it a tiny bit longer to populate sources etc. */
560
 
                        g_timeout_add (1500, (GSourceFunc) g_main_loop_quit, loop);
561
 
                }
562
 
        }
563
 
}
564
 
 
565
 
static void
566
 
state_changed_signal_cb (GDBusProxy *proxy, const char *sender_name, const char *signal_name, GVariant *parameters, GMainLoop *loop)
567
 
{
568
 
        const char *action;
569
 
        GVariant *state;
570
 
        if (g_strcmp0 (signal_name, "StateChanged") != 0) {
571
 
                return;
572
 
        }
573
 
 
574
 
        g_variant_get (parameters, "(sv)", &action, &state);
575
 
        if (g_strcmp0 (action, "load-uri") == 0) {
576
 
                GApplication *app;
577
 
                app = g_object_get_data (G_OBJECT (proxy), "actual-app");
578
 
                state_changed_cb (G_ACTION_GROUP (app), action, state, loop);
579
 
        }
580
 
        g_variant_unref (state);
 
553
 
 
554
static void
 
555
check_loaded_state (GVariant *state)
 
556
{
 
557
        gboolean loaded, scanned;
 
558
 
 
559
        g_variant_get (state, "(bb)", &loaded, &scanned);
 
560
        if (loaded && scanned) {
 
561
                /* give it a tiny bit longer to populate sources etc. */
 
562
                g_timeout_add (1500, (GSourceFunc) g_main_loop_quit, mainloop);
 
563
        }
 
564
}
 
565
 
 
566
static void
 
567
state_changed_cb (GActionGroup *group, const char *action_name, GVariant *state, gpointer data)
 
568
{
 
569
        if (g_strcmp0 (action_name, "load-uri") == 0) {
 
570
                check_loaded_state (state);
 
571
        }
 
572
}
 
573
 
 
574
static void
 
575
action_added_cb (GActionGroup *group, const char *action_name, gpointer data)
 
576
{
 
577
        if (g_strcmp0 (action_name, "load-uri") == 0) {
 
578
                GVariant *state = g_action_group_get_action_state (group, "load-uri");
 
579
                check_loaded_state (state);
 
580
                g_variant_unref (state);
 
581
        }
581
582
}
582
583
 
583
584
static gboolean
671
672
 
672
673
        g_variant_get (state, "(bb)", &loaded, &scanned);
673
674
        if ((loaded && scanned) == FALSE) {
674
 
                GMainLoop *loop;
675
 
                GDBusProxy *app_proxy;
 
675
                GDBusActionGroup *group;
676
676
 
677
677
                rb_debug ("waiting for app startup");
678
 
                loop = g_main_loop_new (NULL, FALSE);
679
 
                g_signal_connect (app, "action-state-changed", G_CALLBACK (state_changed_cb), loop);
680
 
 
681
 
                /* dbus implementation of GApplication doesn't do action state updates yet */
682
 
                app_proxy = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL,
683
 
                                                   "org.gnome.Rhythmbox3",
684
 
                                                   "/org/gnome/Rhythmbox3",
685
 
                                                   "org.gtk.Actions",
686
 
                                                   NULL,
687
 
                                                   &error);
688
 
                if (app_proxy == NULL || proxy_has_name_owner (app_proxy) == FALSE) {
689
 
                        g_warning ("unable to wait for app startup: %s", error->message);
690
 
                        g_clear_error (&error);
691
 
                } else {
692
 
                        g_object_set_data (G_OBJECT (app_proxy), "actual-app", app);
693
 
                        g_signal_connect (app_proxy, "g-signal", G_CALLBACK (state_changed_signal_cb), loop);
694
 
                        g_main_loop_run (loop);
695
 
                        rb_debug ("app is now started enough");
696
 
                }
 
678
                mainloop = g_main_loop_new (NULL, FALSE);
 
679
                group = g_dbus_action_group_get (bus, "org.gnome.Rhythmbox3", "/org/gnome/Rhythmbox3");
 
680
                /* make sure the group gets initialised and put in strict mode */
 
681
                g_action_group_has_action (G_ACTION_GROUP (group), "load-uri");
 
682
                g_signal_connect (group, "action-state-changed", G_CALLBACK (state_changed_cb), NULL);
 
683
                g_signal_connect (group, "action-added", G_CALLBACK (action_added_cb), NULL);
 
684
                g_main_loop_run (mainloop);
 
685
                rb_debug ("app is now started enough");
 
686
                g_object_unref (group);
697
687
        }
698
688
 
699
689
        /* create proxies */