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

« back to all changes in this revision

Viewing changes to gnome-panel/panel-applet-frame.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Sebastien Bacher, Jeremy Bicha
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.13.10 upstream) (2.2.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20110530110449-hinl17kxkcefjw6x
Tags: 1:3.0.2-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in:
  - the new libgweather version is in oneiric, use it
  - drop the python and python-gconf depends, 
    they were added for gnome-panel-add which is still using gconf and buggy
* debian/gnome-panel-data.install:
  - don't install the apport hook, it's only getting gconf datas which 
    doesn't work since gnome-panel uses gsettings
* debian/patches/90_build_fixes.patch:
  - restore build fix from git not applied in the new serie
* debian/patches/01_panel_submenus.patch:
  - don't take that Debian diff, the .menus use the upstream naming in Ubuntu
* debian/patches/06_no_resize_grip.patch:
  - dropped, the issue is fixed in the new version
* debian/patches/50_fix-potfiles.patch:
  - dropped, the issue is fixed in the new version
* debian/watch:
  - track unstable series as well

Drop those delta, since gnome-panel is not the default Ubuntu session now we
can go back to an experience closer to the upstream one: 
* debian/control.in:
  - drop the indicators recommends, unity-2d is the ubuntu fallback session
    so we can get back to use an upstream config for gnome-panel and reduce
    the delta we carry
* debian/patches/04_default_panel_config.patch:
  - don't modify the upstream layout
* debian/patches/05_no_session_delay.patch:
  - no need to tweak the upstream session to optimize it
* debian/patches/16_compiz_workspace_switcher.patch:
  - go back to the upstream switcher behaviour    
* debian/patches/25_dynamic_fusa_detection.patch:
  - not needed since we use the upstream layout, could be ported if someone
    is wanting to do the work though
* debian/patches/30_disable-initial-animation.patch, debian/rules:
  - drop the --disable-initial-animation, that was some login optimization
    but since it's not the default desktop you should go back to the 
    upstream behaviour

[ Jeremy Bicha ]   
* New upstream version
* Merge from Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Recommends gnome-settings-daemon which has the timezone polkit service
* debian/rules:
  - Update translations template.
* debian/gnome-panel-data.install:
  - Install apport hook
  - Install the "About Ubuntu" menu item.
* debian/patches/01_layout.patch:
  - Disabled, Help & About Ubuntu don't fit as well in Gnome Panel 3
* debian/patches/01_panel_submenus.patch.
  - Dropped
* debian/patches/03_dnd_places_link.patch:
  - Disabled, when using Drag'n'Drop from Places menu, install a link launcher
    (.desktop file) instead of copying the entire directory.
* debian/patches/17_about-ubuntu-translation.patch:
  - List ubuntu-about.desktop for translation.
* debian/patches/40_unset_menuproxy.patch:
  - Make sure gnome-panel and the applets don't pick up menu proxies.
* debian/patches/50_fix-potfiles.patch
  - Fix i18n
* debian/patches/85_disable_shutdown_on_ltsp.patch:
  - Suppress the shutdown option in the panel if LTSP_CLIENT is set.
* debian/patches/71_change_bookmark_submenu_limit_value.patch
  - Dropped, picked up by Debian
* debian/patches/18_lockdown_lock_editor.patch:
* debian/patches/90_git_wnck_show_realize.patch:
* debian/patches/90_fix_linking_DSO_link.patch:
* debian/patches/91_gir_annotations.patch
* debian/patches/92_git_calendar_day.patch
* debian/patches/92_git_fix_applets_in_multiscreen.patch:
  - Dropped, applied upstream
* debian/watch:
  - watch unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include <glib/gi18n.h>
31
31
 
32
 
#include <gconf/gconf.h>
33
32
#include <gdk/gdk.h>
34
33
#include <gdk/gdkx.h>
35
34
 
36
35
#include "panel-applets-manager.h"
37
 
#include "panel-profile.h"
 
36
#include "panel-bindings.h"
38
37
#include "panel.h"
39
38
#include "applet.h"
40
39
#include "panel-marshal.h"
41
40
#include "panel-background.h"
 
41
#include "panel-layout.h"
42
42
#include "panel-lockdown.h"
 
43
#include "panel-object-loader.h"
 
44
#include "panel-schemas.h"
43
45
#include "panel-stock-icons.h"
44
46
#include "xstuff.h"
45
47
#include "panel-compatibility.h"
52
54
                                                PanelWidget *panel,
53
55
                                                const char  *id);
54
56
 
55
 
static void panel_applet_frame_load            (const gchar *iid,
 
57
static void panel_applet_frame_load_helper     (const gchar *iid,
56
58
                                                PanelWidget *panel,
57
 
                                                gboolean     locked,
58
 
                                                int          position,
59
 
                                                gboolean     exactpos,
60
 
                                                const char  *id);
 
59
                                                const char  *id,
 
60
                                                GSettings   *settings);
61
61
 
62
62
struct _PanelAppletFrameActivating {
63
 
        gboolean     locked;
64
63
        PanelWidget *panel;
65
 
        int          position;
66
 
        gboolean     exactpos;
67
64
        char        *id;
 
65
        GSettings   *settings;
68
66
};
69
67
 
70
68
/* PanelAppletFrame implementation */
74
72
#define PANEL_APPLET_FRAME_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_FRAME, PanelAppletFramePrivate))
75
73
 
76
74
#define HANDLE_SIZE 10
77
 
#define PANEL_APPLET_PREFS_KEY "/apps/panel/applets/%s/prefs"
78
75
 
79
76
struct _PanelAppletFramePrivate {
80
77
        PanelWidget     *panel;
90
87
        guint            has_handle : 1;
91
88
};
92
89
 
93
 
static void
94
 
panel_applet_frame_paint (GtkWidget    *widget,
95
 
                          GdkRectangle *area)
 
90
static gboolean
 
91
panel_applet_frame_draw (GtkWidget *widget,
 
92
                         cairo_t   *cr)
96
93
{
97
 
        PanelAppletFrame *frame;
 
94
        PanelAppletFrame *frame = PANEL_APPLET_FRAME (widget);
 
95
        GtkStyleContext *context;
98
96
 
99
 
        frame = PANEL_APPLET_FRAME (widget);
 
97
        if (GTK_WIDGET_CLASS (panel_applet_frame_parent_class)->draw)
 
98
                GTK_WIDGET_CLASS (panel_applet_frame_parent_class)->draw (widget, cr);
100
99
 
101
100
        if (!frame->priv->has_handle)
102
 
                return;
103
 
  
104
 
        if (gtk_widget_is_drawable (widget)) {
105
 
                GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
106
 
 
107
 
                switch (frame->priv->orientation) {
108
 
                case PANEL_ORIENTATION_TOP:
109
 
                case PANEL_ORIENTATION_BOTTOM:
110
 
                        orientation = GTK_ORIENTATION_VERTICAL;
111
 
                        break;
112
 
                case PANEL_ORIENTATION_LEFT:
113
 
                case PANEL_ORIENTATION_RIGHT:
114
 
                        orientation = GTK_ORIENTATION_HORIZONTAL;
115
 
                        break;
116
 
                default:
117
 
                        g_assert_not_reached ();
118
 
                        break;
119
 
                }
120
 
 
121
 
                gtk_paint_handle (
122
 
                        gtk_widget_get_style (widget), gtk_widget_get_window (widget),
123
 
                        gtk_widget_get_state (widget),
124
 
                        GTK_SHADOW_OUT,
125
 
                        area, widget, "handlebox",
126
 
                        frame->priv->handle_rect.x,
127
 
                        frame->priv->handle_rect.y,
128
 
                        frame->priv->handle_rect.width,
129
 
                        frame->priv->handle_rect.height,
130
 
                        orientation);
131
 
        }
132
 
}
133
 
 
134
 
static gboolean
135
 
panel_applet_frame_expose (GtkWidget      *widget,
136
 
                           GdkEventExpose *event)
137
 
{
138
 
        if (gtk_widget_is_drawable (widget)) {
139
 
                GTK_WIDGET_CLASS (panel_applet_frame_parent_class)->expose_event (widget, event);
140
 
 
141
 
                panel_applet_frame_paint (widget, &event->area);
142
 
        }
143
 
 
144
 
        return FALSE;
 
101
                return FALSE;
 
102
 
 
103
        context = gtk_widget_get_style_context (widget);
 
104
        gtk_style_context_save (context);
 
105
        gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget));
 
106
 
 
107
        cairo_save (cr);
 
108
        cairo_rectangle (cr,
 
109
                         frame->priv->handle_rect.x,
 
110
                         frame->priv->handle_rect.y,
 
111
                         frame->priv->handle_rect.width,
 
112
                         frame->priv->handle_rect.height);
 
113
        cairo_clip (cr);
 
114
        gtk_render_handle (context, cr,
 
115
                           0, 0,
 
116
                           gtk_widget_get_allocated_width (widget),
 
117
                           gtk_widget_get_allocated_height (widget));
 
118
        cairo_restore (cr);
 
119
 
 
120
        gtk_style_context_restore (context);
 
121
 
 
122
        return FALSE;
145
123
}
146
124
 
147
125
static void
167
145
}
168
146
 
169
147
static void
170
 
panel_applet_frame_size_request (GtkWidget      *widget,
171
 
                                 GtkRequisition *requisition)
172
 
{
173
 
        PanelAppletFrame *frame;
174
 
        GtkBin           *bin;
175
 
        GtkWidget        *child;
176
 
        GtkRequisition    child_requisition;
177
 
        guint             border_width;
178
 
 
179
 
        frame = PANEL_APPLET_FRAME (widget);
180
 
        bin = GTK_BIN (widget);
181
 
 
182
 
        if (!frame->priv->has_handle) {
183
 
                GTK_WIDGET_CLASS (panel_applet_frame_parent_class)->size_request (widget, requisition);
184
 
                return;
185
 
        }
186
 
 
187
 
        child = gtk_bin_get_child (bin);
188
 
        if (child && gtk_widget_get_visible (child)) {
189
 
                gtk_widget_size_request (child, &child_requisition);
190
 
 
191
 
                requisition->width  = child_requisition.width;
192
 
                requisition->height = child_requisition.height;
193
 
        }
194
 
 
195
 
        border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
196
 
        requisition->width += border_width;
197
 
        requisition->height += border_width;
198
 
 
199
 
        switch (frame->priv->orientation) {
200
 
        case PANEL_ORIENTATION_TOP:
201
 
        case PANEL_ORIENTATION_BOTTOM:
202
 
                requisition->width += HANDLE_SIZE;
203
 
                break;
204
 
        case PANEL_ORIENTATION_LEFT:
205
 
        case PANEL_ORIENTATION_RIGHT:
206
 
                requisition->height += HANDLE_SIZE;
 
148
panel_applet_frame_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
 
149
{
 
150
        PanelAppletFrame *frame;
 
151
        GtkBin           *bin;
 
152
        GtkWidget        *child;
 
153
        guint             border_width;
 
154
 
 
155
        frame = PANEL_APPLET_FRAME (widget);
 
156
        bin = GTK_BIN (widget);
 
157
 
 
158
        if (!frame->priv->has_handle) {
 
159
                GTK_WIDGET_CLASS (panel_applet_frame_parent_class)->get_preferred_width (widget, minimal_width, natural_width);
 
160
                return;
 
161
        }
 
162
 
 
163
        child = gtk_bin_get_child (bin);
 
164
        if (child && gtk_widget_get_visible (child))
 
165
                gtk_widget_get_preferred_width (child, minimal_width, natural_width);
 
166
 
 
167
        border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
168
        *minimal_width += border_width;
 
169
        *natural_width += border_width;
 
170
 
 
171
        switch (frame->priv->orientation) {
 
172
        case PANEL_ORIENTATION_TOP:
 
173
        case PANEL_ORIENTATION_BOTTOM:
 
174
                *minimal_width += HANDLE_SIZE;
 
175
                *natural_width += HANDLE_SIZE;
 
176
                break;
 
177
        case PANEL_ORIENTATION_LEFT:
 
178
        case PANEL_ORIENTATION_RIGHT:
 
179
                break;
 
180
        default:
 
181
                g_assert_not_reached ();
 
182
                break;
 
183
        }
 
184
}
 
185
 
 
186
static void
 
187
panel_applet_frame_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
 
188
{
 
189
        PanelAppletFrame *frame;
 
190
        GtkBin           *bin;
 
191
        GtkWidget        *child;
 
192
        guint             border_width;
 
193
 
 
194
        frame = PANEL_APPLET_FRAME (widget);
 
195
        bin = GTK_BIN (widget);
 
196
 
 
197
        if (!frame->priv->has_handle) {
 
198
                GTK_WIDGET_CLASS (panel_applet_frame_parent_class)->get_preferred_height (widget, minimal_height, natural_height);
 
199
                return;
 
200
        }
 
201
 
 
202
        child = gtk_bin_get_child (bin);
 
203
        if (child && gtk_widget_get_visible (child))
 
204
                gtk_widget_get_preferred_height (child, minimal_height, natural_height);
 
205
 
 
206
        border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
207
        *minimal_height += border_width;
 
208
        *natural_height += border_width;
 
209
 
 
210
        switch (frame->priv->orientation) {
 
211
        case PANEL_ORIENTATION_LEFT:
 
212
        case PANEL_ORIENTATION_RIGHT:
 
213
                *minimal_height += HANDLE_SIZE;
 
214
                *natural_height += HANDLE_SIZE;
 
215
                break;
 
216
        case PANEL_ORIENTATION_TOP:
 
217
        case PANEL_ORIENTATION_BOTTOM:
207
218
                break;
208
219
        default:
209
220
                g_assert_not_reached ();
336
347
{
337
348
        PanelAppletFrame *frame;
338
349
        gboolean          handled = FALSE;
 
350
        guint             modifiers;
 
351
        GdkDisplay       *display;
 
352
        GdkDevice        *pointer;
 
353
        GdkDeviceManager *device_manager;
339
354
 
340
355
        frame = PANEL_APPLET_FRAME (widget);
341
356
 
345
360
        if (event->window != gtk_widget_get_window (widget))
346
361
                return FALSE;
347
362
 
 
363
        modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
 
364
 
348
365
        switch (event->button) {
349
366
        case 1:
350
367
        case 2:
351
368
                if (button_event_in_rect (event, &frame->priv->handle_rect)) {
352
 
                        if (event->type == GDK_BUTTON_PRESS ||
353
 
                            event->type == GDK_2BUTTON_PRESS) {
 
369
                        if ((event->type == GDK_BUTTON_PRESS ||
 
370
                             event->type == GDK_2BUTTON_PRESS) &&
 
371
                            modifiers == panel_bindings_get_mouse_button_modifier_keymask ()){
354
372
                                panel_widget_applet_drag_start (
355
373
                                        frame->priv->panel, GTK_WIDGET (frame),
356
 
                                        PW_DRAG_OFF_CURSOR, event->time);
 
374
                                        event->time);
357
375
                                handled = TRUE;
358
376
                        } else if (event->type == GDK_BUTTON_RELEASE) {
359
377
                                panel_widget_applet_drag_end (frame->priv->panel);
364
382
        case 3:
365
383
                if (event->type == GDK_BUTTON_PRESS ||
366
384
                    event->type == GDK_2BUTTON_PRESS) {
367
 
                        gdk_pointer_ungrab (GDK_CURRENT_TIME);
 
385
                        display = gtk_widget_get_display (widget);
 
386
                        device_manager = gdk_display_get_device_manager (display);
 
387
                        pointer = gdk_device_manager_get_client_pointer (device_manager);
 
388
                        gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
368
389
 
369
 
                        PANEL_APPLET_FRAME_GET_CLASS (frame)->popup_menu (frame,
370
 
                                                                          event->button,
371
 
                                                                          event->time);
 
390
                        if (modifiers == panel_bindings_get_mouse_button_modifier_keymask ())
 
391
                                PANEL_APPLET_FRAME_GET_CLASS (frame)->popup_edit_menu (frame,
 
392
                                                                                       event->button,
 
393
                                                                                       event->time);
 
394
                        else
 
395
                                PANEL_APPLET_FRAME_GET_CLASS (frame)->popup_menu (frame,
 
396
                                                                                  event->button,
 
397
                                                                                  event->time);
372
398
 
373
399
                        handled = TRUE;
374
400
                } else if (event->type == GDK_BUTTON_RELEASE)
388
414
 
389
415
        panel_applets_manager_factory_deactivate (frame->priv->iid);
390
416
 
391
 
        panel_lockdown_notify_remove (G_CALLBACK (panel_applet_frame_sync_menu_state),
392
 
                                      frame);
393
 
 
394
417
        g_free (frame->priv->iid);
395
418
        frame->priv->iid = NULL;
396
419
 
405
428
 
406
429
        gobject_class->finalize = panel_applet_frame_finalize;
407
430
 
408
 
        widget_class->expose_event         = panel_applet_frame_expose;
409
 
        widget_class->size_request         = panel_applet_frame_size_request;
 
431
        widget_class->draw                 = panel_applet_frame_draw;
 
432
        widget_class->get_preferred_width  = panel_applet_frame_get_preferred_width;
 
433
        widget_class->get_preferred_height = panel_applet_frame_get_preferred_height;
410
434
        widget_class->size_allocate        = panel_applet_frame_size_allocate;
411
435
        widget_class->button_press_event   = panel_applet_frame_button_changed;
412
436
        widget_class->button_release_event = panel_applet_frame_button_changed;
431
455
        PANEL_APPLET_FRAME_GET_CLASS (frame)->init_properties (frame);
432
456
}
433
457
 
434
 
void
435
 
panel_applet_frame_sync_menu_state (PanelAppletFrame *frame)
 
458
static void
 
459
panel_applet_frame_sync_menu_state (PanelLockdown *lockdown,
 
460
                                    gpointer       user_data)
436
461
{
437
 
        PanelWidget *panel_widget;
438
 
        gboolean     locked_down;
439
 
        gboolean     locked;
440
 
        gboolean     lockable;
441
 
        gboolean     movable;
442
 
        gboolean     removable;
 
462
        PanelAppletFrame *frame = PANEL_APPLET_FRAME (user_data);
 
463
        PanelWidget      *panel_widget;
 
464
        gboolean          locked_down;
 
465
        gboolean          movable;
 
466
        gboolean          removable;
443
467
 
444
468
        panel_widget = PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (frame)));
445
469
 
446
470
        movable = panel_applet_can_freely_move (frame->priv->applet_info);
447
 
        removable = panel_profile_id_lists_are_writable ();
448
 
        lockable = panel_applet_lockable (frame->priv->applet_info);
449
 
 
450
 
        locked = panel_widget_get_applet_locked (panel_widget, GTK_WIDGET (frame));
451
 
        locked_down = panel_lockdown_get_locked_down ();
452
 
 
453
 
        PANEL_APPLET_FRAME_GET_CLASS (frame)->sync_menu_state (frame, movable, removable, lockable, locked, locked_down);
 
471
        removable = panel_layout_is_writable ();
 
472
        locked_down = panel_lockdown_get_panels_locked_down_s ();
 
473
 
 
474
        PANEL_APPLET_FRAME_GET_CLASS (frame)->sync_menu_state (frame, movable, removable, locked_down);
454
475
}
455
476
 
456
477
void
539
560
        frame->priv->panel = frame_act->panel;
540
561
        gtk_widget_show_all (GTK_WIDGET (frame));
541
562
 
542
 
        info = panel_applet_register (GTK_WIDGET (frame), GTK_WIDGET (frame),
543
 
                                      NULL, frame->priv->panel,
544
 
                                      frame_act->locked, frame_act->position,
545
 
                                      frame_act->exactpos, PANEL_OBJECT_APPLET,
546
 
                                      frame_act->id);
 
563
        info = panel_applet_register (GTK_WIDGET (frame), frame->priv->panel,
 
564
                                      PANEL_OBJECT_APPLET, frame_act->id,
 
565
                                      frame_act->settings,
 
566
                                      GTK_WIDGET (frame), NULL);
547
567
        frame->priv->applet_info = info;
548
568
 
549
569
        panel_widget_set_applet_size_constrained (frame->priv->panel,
550
570
                                                  GTK_WIDGET (frame), TRUE);
551
571
 
552
 
        panel_applet_frame_sync_menu_state (frame);
 
572
 
 
573
        panel_lockdown_on_notify (panel_lockdown_get (),
 
574
                                  NULL,
 
575
                                  G_OBJECT (frame),
 
576
                                  panel_applet_frame_sync_menu_state,
 
577
                                  frame);
 
578
        panel_applet_frame_sync_menu_state (panel_lockdown_get (), frame);
 
579
 
553
580
        panel_applet_frame_init_properties (frame);
554
581
 
555
 
        panel_lockdown_notify_add (G_CALLBACK (panel_applet_frame_sync_menu_state),
556
 
                                   frame);
557
 
 
558
 
        panel_applet_stop_loading (frame_act->id);
 
582
        panel_object_loader_stop_loading (frame_act->id);
559
583
        panel_applet_frame_activating_free (frame_act);
560
584
}
561
585
 
659
683
                PanelWidget *panel;
660
684
                char        *iid;
661
685
                char        *id = NULL;
662
 
                int          position = -1;
663
 
                gboolean     locked = FALSE;
 
686
                GSettings   *settings = NULL;
664
687
 
665
688
                panel = frame->priv->panel;
666
689
                iid   = g_strdup (frame->priv->iid);
667
690
 
668
691
                if (info) {
669
692
                        id = g_strdup (info->id);
670
 
                        position  = panel_applet_get_position (info);
671
 
                        locked = panel_widget_get_applet_locked (panel, info->widget);
 
693
                        settings = panel_applet_get_settings (info);
 
694
                        g_object_ref (settings);
672
695
                        panel_applet_clean (info);
673
696
                }
674
697
 
675
 
                panel_applet_frame_load (iid, panel, locked,
676
 
                                         position, TRUE, id);
 
698
                panel_applet_frame_load_helper (iid, panel, id, settings);
677
699
 
678
700
                g_free (iid);
679
701
                g_free (id);
 
702
                if (settings)
 
703
                        g_object_unref (settings);
680
704
 
681
705
        } else if (info) {
682
706
                /* if we can't write to applets list we can't really delete
683
707
                   it, so we'll just ignore this.  FIXME: handle this
684
708
                   more correctly I suppose. */
685
 
                if (panel_profile_id_lists_are_writable ())
686
 
                        panel_profile_delete_object (info);
 
709
                if (panel_layout_is_writable ())
 
710
                        panel_layout_delete_object (panel_applet_get_id (info));
687
711
        }
688
712
 
689
713
        g_object_unref (frame);
759
783
        info = frame->priv->applet_info;
760
784
        frame->priv->applet_info = NULL;
761
785
 
762
 
        panel_profile_delete_object (info);
 
786
        panel_layout_delete_object (panel_applet_get_id (info));
763
787
}
764
788
 
765
789
void
773
797
 
774
798
        panel_widget_applet_drag_start (PANEL_WIDGET (parent),
775
799
                                        widget,
776
 
                                        PW_DRAG_OFF_CENTER,
777
800
                                        GDK_CURRENT_TIME);
778
801
}
779
802
 
780
 
void
781
 
_panel_applet_frame_applet_lock (PanelAppletFrame *frame,
782
 
                                 gboolean          locked)
783
 
{
784
 
        PanelWidget *panel_widget = PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (frame)));
785
 
 
786
 
        if (panel_widget_get_applet_locked (panel_widget, GTK_WIDGET (frame)) == locked)
787
 
                return;
788
 
 
789
 
        panel_applet_toggle_locked (frame->priv->applet_info);
790
 
}
791
 
 
792
803
/* Generic methods */
793
804
 
794
805
static GSList *no_reload_applets = NULL;
801
812
static void
802
813
panel_applet_frame_activating_free (PanelAppletFrameActivating *frame_act)
803
814
{
 
815
        g_object_unref (frame_act->settings);
804
816
        g_free (frame_act->id);
805
817
        g_slice_free (PanelAppletFrameActivating, frame_act);
806
818
}
808
820
GdkScreen *
809
821
panel_applet_frame_activating_get_screen (PanelAppletFrameActivating *frame_act)
810
822
{
811
 
        return gtk_widget_get_screen (frame_act->panel);
 
823
        return gtk_widget_get_screen (GTK_WIDGET (frame_act->panel));
812
824
}
813
825
 
814
826
PanelOrientation
824
836
}
825
837
 
826
838
gboolean
827
 
panel_applet_frame_activating_get_locked (PanelAppletFrameActivating *frame_act)
828
 
{
829
 
        return frame_act->locked;
830
 
}
831
 
 
832
 
gboolean
833
839
panel_applet_frame_activating_get_locked_down (PanelAppletFrameActivating *frame_act)
834
840
{
835
 
        return panel_lockdown_get_locked_down ();
 
841
        return panel_lockdown_get_panels_locked_down_s ();
 
842
}
 
843
 
 
844
gchar *
 
845
panel_applet_frame_activating_get_settings_path (PanelAppletFrameActivating *frame_act)
 
846
{
 
847
        char *path;
 
848
        char *path_instance;
 
849
 
 
850
        g_object_get (frame_act->settings, "path", &path, NULL);
 
851
        path_instance = g_strdup_printf ("%s%s", path,
 
852
                                         PANEL_LAYOUT_OBJECT_CONFIG_SUFFIX);
 
853
        g_free (path);
 
854
 
 
855
        return path_instance;
836
856
}
837
857
 
838
858
gchar *
839
859
panel_applet_frame_activating_get_conf_path (PanelAppletFrameActivating *frame_act)
840
860
{
841
 
        return g_strdup_printf (PANEL_APPLET_PREFS_KEY, frame_act->id);
 
861
        return panel_layout_object_get_gconf_path (frame_act->id);
842
862
}
843
863
 
844
864
static void
849
869
        gtk_widget_destroy (dialog);
850
870
 
851
871
        if (response == LOADING_FAILED_RESPONSE_DELETE &&
852
 
            !panel_lockdown_get_locked_down () &&
853
 
            panel_profile_id_lists_are_writable ()) {
 
872
            !panel_lockdown_get_panels_locked_down_s () &&
 
873
            panel_layout_is_writable ()) {
854
874
                GSList *item;
855
875
 
856
876
                item = g_slist_find_custom (no_reload_applets, id,
861
881
                                                                 item);
862
882
                }
863
883
 
864
 
                panel_profile_remove_from_list (PANEL_GCONF_APPLETS, id);
 
884
                panel_layout_delete_object (id);
865
885
        }
866
886
 
867
887
        g_free (id);
879
899
        no_reload_applets = g_slist_prepend (no_reload_applets,
880
900
                                             g_strdup (id));
881
901
 
882
 
        locked_down = panel_lockdown_get_locked_down ();
 
902
        locked_down = panel_lockdown_get_panels_locked_down_s ();
883
903
 
884
904
        problem_txt = g_strdup_printf (_("The panel encountered a problem "
885
905
                                         "while loading \"%s\"."),
924
944
 
925
945
        /* Note: this call will free the memory for id, so the variable should
926
946
         * not get accessed afterwards. */
927
 
        panel_applet_stop_loading (id);
 
947
        panel_object_loader_stop_loading (id);
928
948
}
929
949
 
930
950
static void
931
 
panel_applet_frame_load (const gchar *iid,
932
 
                         PanelWidget *panel,
933
 
                         gboolean     locked,
934
 
                         int          position,
935
 
                         gboolean     exactpos,
936
 
                         const char  *id)
 
951
panel_applet_frame_load_helper (const gchar *iid,
 
952
                                PanelWidget *panel,
 
953
                                const char  *id,
 
954
                                GSettings   *settings)
937
955
{
938
956
        PanelAppletFrameActivating *frame_act;
939
957
 
943
961
 
944
962
        if (g_slist_find_custom (no_reload_applets, id,
945
963
                                 (GCompareFunc) strcmp)) {
946
 
                panel_applet_stop_loading (id);
 
964
                panel_object_loader_stop_loading (id);
947
965
                return;
948
966
        }
949
967
 
950
 
        if (panel_lockdown_is_applet_disabled (iid)) {
951
 
                panel_applet_stop_loading (id);
 
968
        if (panel_lockdown_is_applet_disabled (panel_lockdown_get (), iid)) {
 
969
                panel_object_loader_stop_loading (id);
952
970
                return;
953
971
        }
954
972
 
955
973
        frame_act = g_slice_new0 (PanelAppletFrameActivating);
956
 
        frame_act->locked   = locked;
957
974
        frame_act->panel    = panel;
958
 
        frame_act->position = position;
959
 
        frame_act->exactpos = exactpos;
960
975
        frame_act->id       = g_strdup (id);
 
976
        frame_act->settings = g_object_ref (settings);
961
977
 
962
978
        if (!panel_applets_manager_load_applet (iid, frame_act)) {
963
979
                panel_applet_frame_loading_failed (iid, panel, id);
966
982
}
967
983
 
968
984
void
969
 
panel_applet_frame_load_from_gconf (PanelWidget *panel_widget,
970
 
                                    gboolean     locked,
971
 
                                    int          position,
972
 
                                    const char  *id)
 
985
panel_applet_frame_load (PanelWidget *panel_widget,
 
986
                         const char  *id,
 
987
                         GSettings   *settings)
973
988
{
974
989
        gchar *applet_iid;
975
990
 
976
991
        g_return_if_fail (panel_widget != NULL);
977
992
        g_return_if_fail (id != NULL);
978
993
 
979
 
        applet_iid = panel_compatibility_get_applet_iid (id);
 
994
        applet_iid = panel_compatibility_get_applet_iid (settings, id);
980
995
        if (!applet_iid) {
981
 
                panel_applet_stop_loading (id);
 
996
                panel_object_loader_stop_loading (id);
982
997
                return;
983
998
        }
984
999
 
985
 
        panel_applet_frame_load (applet_iid, panel_widget,
986
 
                                 locked, position, TRUE, id);
 
1000
        panel_applet_frame_load_helper (applet_iid, panel_widget, id, settings);
987
1001
 
988
1002
        g_free (applet_iid);
989
1003
}
990
1004
 
991
1005
void
992
 
panel_applet_frame_create (PanelToplevel *toplevel,
993
 
                           int            position,
994
 
                           const char    *iid)
 
1006
panel_applet_frame_create (PanelToplevel       *toplevel,
 
1007
                           PanelObjectPackType  pack_type,
 
1008
                           int                  pack_index,
 
1009
                           const char          *iid)
995
1010
{
996
 
        GConfClient *client;
997
 
        const char  *key;
998
 
        char        *id;
999
 
 
1000
1011
        g_return_if_fail (iid != NULL);
1001
1012
 
1002
 
        client =  panel_gconf_get_client ();
1003
 
 
1004
 
        id = panel_profile_prepare_object (PANEL_OBJECT_APPLET, toplevel, position, FALSE);
1005
 
 
1006
 
        key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_iid");
1007
 
        gconf_client_set_string (client, key, iid, NULL);
1008
 
 
1009
 
        panel_profile_add_to_list (PANEL_GCONF_APPLETS, id);
1010
 
 
1011
 
        g_free (id);
1012
 
}
1013
 
 
1014
 
/** \brief  Gets the IID for a panel applet frame
1015
 
        \param  frame  Applet frame
1016
 
        \return The IID of the applet or NULL on error
1017
 
*/
1018
 
const gchar * 
1019
 
panel_applet_frame_get_iid (PanelAppletFrame * frame)
1020
 
{
1021
 
        g_return_val_if_fail (PANEL_IS_APPLET_FRAME (frame), NULL);
1022
 
 
1023
 
        return frame->priv->iid;
 
1013
        panel_layout_object_create (PANEL_OBJECT_APPLET,
 
1014
                                    iid,
 
1015
                                    panel_toplevel_get_id (toplevel),
 
1016
                                    pack_type, pack_index);
1024
1017
}