~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to gnome-panel/libpanel-applet-private/panel-applet-container.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.3.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: james.westby@ubuntu.com-20110530110449-ut1tc5t61rpvf9e3
Tags: upstream-3.0.2
ImportĀ upstreamĀ versionĀ 3.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 */
22
22
 
23
23
#include <string.h>
 
24
#include <gtk/gtkx.h>
24
25
#include "panel-applet-container.h"
25
26
#include "panel-marshal.h"
26
27
 
40
41
        APPLET_BROKEN,
41
42
        APPLET_MOVE,
42
43
        APPLET_REMOVE,
43
 
        APPLET_LOCK,
44
44
        CHILD_PROPERTY_CHANGED,
45
45
        LAST_SIGNAL
46
46
};
53
53
} AppletPropertyInfo;
54
54
 
55
55
static const AppletPropertyInfo applet_properties [] = {
56
 
        { "prefs-key",   "PrefsKey" },
57
 
        { "orient",      "Orient" },
58
 
        { "size",        "Size" },
59
 
        { "size-hints",  "SizeHints" },
60
 
        { "background",  "Background" },
61
 
        { "flags",       "Flags" },
62
 
        { "locked",      "Locked" },
63
 
        { "locked-down", "LockedDown" }
 
56
        { "settings-path", "SettingsPath" },
 
57
        { "prefs-key",     "PrefsKey" },
 
58
        { "orient",        "Orient" },
 
59
        { "size",          "Size" },
 
60
        { "size-hints",    "SizeHints" },
 
61
        { "background",    "Background" },
 
62
        { "flags",         "Flags" },
 
63
        { "locked-down",   "LockedDown" }
64
64
};
65
65
 
66
66
#define PANEL_APPLET_CONTAINER_GET_PRIVATE(o) \
188
188
                              g_cclosure_marshal_VOID__VOID,
189
189
                              G_TYPE_NONE,
190
190
                              0);
191
 
        signals[APPLET_LOCK] =
192
 
                g_signal_new ("applet-lock",
193
 
                              G_TYPE_FROM_CLASS (klass),
194
 
                              G_SIGNAL_RUN_LAST,
195
 
                              G_STRUCT_OFFSET (PanelAppletContainerClass, applet_lock),
196
 
                              NULL,
197
 
                              NULL,
198
 
                              g_cclosure_marshal_VOID__BOOLEAN,
199
 
                              G_TYPE_NONE,
200
 
                              1, G_TYPE_BOOLEAN);
201
191
        signals[CHILD_PROPERTY_CHANGED] =
202
192
                g_signal_new ("child-property-changed",
203
193
                              G_TYPE_FROM_CLASS (klass),
272
262
                g_signal_emit (container, signals[APPLET_MOVE], 0);
273
263
        } else if (g_strcmp0 (signal_name, "RemoveFromPanel") == 0) {
274
264
                g_signal_emit (container, signals[APPLET_REMOVE], 0);
275
 
        } else if (g_strcmp0 (signal_name, "Lock") == 0) {
276
 
                g_signal_emit (container, signals[APPLET_LOCK], 0, TRUE);
277
 
        } else if (g_strcmp0 (signal_name, "Unlock") == 0) {
278
 
                g_signal_emit (container, signals[APPLET_LOCK], 0, FALSE);
279
265
        }
280
266
}
281
267
 
446
432
 
447
433
static void
448
434
panel_applet_container_get_applet (PanelAppletContainer *container,
 
435
                                   GdkScreen            *screen,
449
436
                                   const gchar          *iid,
450
437
                                   GVariant             *props,
451
438
                                   GCancellable         *cancellable,
454
441
{
455
442
        GSimpleAsyncResult *result;
456
443
        AppletFactoryData  *data;
457
 
        gint                screen;
 
444
        gint                screen_number;
458
445
        gchar              *bus_name;
459
446
        gchar              *factory_id;
460
447
        gchar              *applet_id;
479
466
        factory_id = g_strndup (iid, strlen (iid) - strlen (applet_id));
480
467
        applet_id += 2;
481
468
 
482
 
        screen = gdk_screen_get_number (gtk_widget_get_screen (container->priv->socket));
 
469
        /* we can't use the screen of the container widget since it's not in a
 
470
         * widget hierarchy yet */
 
471
        screen_number = gdk_screen_get_number (screen);
483
472
 
484
473
        data = g_new (AppletFactoryData, 1);
485
474
        data->result = result;
486
475
        data->factory_id = factory_id;
487
 
        data->parameters = g_variant_new ("(si*)", applet_id, screen, props);
 
476
        data->parameters = g_variant_new ("(si*)", applet_id, screen_number, props);
488
477
        data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
489
478
 
490
479
        bus_name = g_strdup_printf (PANEL_APPLET_BUS_NAME, factory_id);
503
492
 
504
493
void
505
494
panel_applet_container_add (PanelAppletContainer *container,
 
495
                            GdkScreen            *screen,
506
496
                            const gchar          *iid,
507
497
                            GCancellable         *cancellable,
508
498
                            GAsyncReadyCallback   callback,
514
504
 
515
505
        panel_applet_container_cancel_pending_operations (container);
516
506
 
517
 
        panel_applet_container_get_applet (container, iid, properties,
 
507
        panel_applet_container_get_applet (container, screen, iid, properties,
518
508
                                           cancellable, callback, user_data);
519
509
}
520
510
 
793
783
 
794
784
        return !g_simple_async_result_propagate_error (simple, error);
795
785
}
 
786
 
 
787
void
 
788
panel_applet_container_child_popup_edit_menu (PanelAppletContainer *container,
 
789
                                              guint                 button,
 
790
                                              guint32               timestamp,
 
791
                                              GCancellable         *cancellable,
 
792
                                              GAsyncReadyCallback   callback,
 
793
                                              gpointer              user_data)
 
794
{
 
795
        GSimpleAsyncResult *result;
 
796
        GDBusProxy         *proxy = container->priv->applet_proxy;
 
797
 
 
798
        if (!proxy)
 
799
                return;
 
800
 
 
801
        result = g_simple_async_result_new (G_OBJECT (container),
 
802
                                            callback,
 
803
                                            user_data,
 
804
                                            panel_applet_container_child_popup_edit_menu);
 
805
 
 
806
        g_dbus_connection_call (g_dbus_proxy_get_connection (proxy),
 
807
                                g_dbus_proxy_get_name (proxy),
 
808
                                g_dbus_proxy_get_object_path (proxy),
 
809
                                PANEL_APPLET_INTERFACE,
 
810
                                "PopupEditMenu",
 
811
                                g_variant_new ("(uu)", button, timestamp),
 
812
                                NULL,
 
813
                                G_DBUS_CALL_FLAGS_NO_AUTO_START,
 
814
                                -1, cancellable,
 
815
                                child_popup_menu_cb,
 
816
                                result);
 
817
}
 
818
 
 
819
gboolean
 
820
panel_applet_container_child_popup_edit_menu_finish (PanelAppletContainer *container,
 
821
                                                     GAsyncResult         *result,
 
822
                                                     GError              **error)
 
823
{
 
824
        GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
 
825
 
 
826
        g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == panel_applet_container_child_popup_edit_menu);
 
827
 
 
828
        return !g_simple_async_result_propagate_error (simple, error);
 
829
}