~ubuntu-branches/ubuntu/natty/gnome-panel/natty

« back to all changes in this revision

Viewing changes to gnome-panel/applet.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-11-09 15:06:29 UTC
  • mfrom: (1.13.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101109150629-whuwed41qbhpxk9j
Tags: 1:2.32.0.2-0ubuntu1
* New upstream version
* debian/control.in:
  - recommends python-gconf and python rather than depends on it,
    gnome-panel-add is the only code to use those
  - clean the python-gnome2 depends
  - list the new binaries for libpanel-applet3 and gir
  - set a new gnome-panel-bonobo binary with the bonobo loader
  - recommends gnome-settings-daemon which has the timezone polkit service
  - updated glib requirement and the build depends for the gir build
  - use dh-autoreconf
* Updated the .install files for the new version
* debian/patches/01_layout.patch:
  - new version update
* debian/patches/04_default_panel_config.patch:
  - updated the layout
* debian/patches/90_git_wnck_show_realize.patch,
  debian/patches/91_git_wnck_pager_update.patch:
 - the fixes are in the next version
* debian/patches/99_ltmain_as-needed.patch:
  - dropped, it's not required with --as-needed by default in natty
* debian/rules:
  - call dh_girepository
  - comment the ldflag options to workaround build issues 
  - updated shlibs version
  - use dh-autoreconf rather than the cdbs way

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
static guint   queued_position_source = 0;
44
44
 
45
45
 
 
46
static inline PanelWidget *
 
47
panel_applet_get_panel_widget (AppletInfo *info)
 
48
{
 
49
        return PANEL_WIDGET (gtk_widget_get_parent (info->widget));
 
50
}
 
51
 
46
52
static void
47
53
panel_applet_set_dnd_enabled (AppletInfo *info,
48
54
                              gboolean    dnd_enabled)
58
64
        case PANEL_OBJECT_LAUNCHER:
59
65
                panel_launcher_set_dnd_enabled (info->data, dnd_enabled);
60
66
                break;
61
 
        case PANEL_OBJECT_BONOBO:
 
67
        case PANEL_OBJECT_APPLET:
62
68
                break;
63
69
        case PANEL_OBJECT_LOGOUT:
64
70
        case PANEL_OBJECT_LOCK:
82
88
        PanelWidget *panel_widget;
83
89
        gboolean     locked;
84
90
 
85
 
        panel_widget = PANEL_WIDGET (info->widget->parent);
 
91
        panel_widget = panel_applet_get_panel_widget (info);
86
92
        
87
93
        locked = panel_widget_toggle_applet_locked (panel_widget, info->widget);
88
94
 
109
115
static void
110
116
move_applet_callback (GtkWidget *widget, AppletInfo *info)
111
117
{
 
118
        GtkWidget   *parent;
112
119
        PanelWidget *panel;
113
120
 
114
121
        g_return_if_fail (info != NULL);
115
122
        g_return_if_fail (info->widget != NULL);
116
 
        g_return_if_fail (info->widget->parent != NULL);
117
 
        g_return_if_fail (PANEL_IS_WIDGET (info->widget->parent));
118
 
 
119
 
        panel = PANEL_WIDGET (info->widget->parent);
 
123
 
 
124
        parent = gtk_widget_get_parent (info->widget);
 
125
 
 
126
        g_return_if_fail (parent != NULL);
 
127
        g_return_if_fail (PANEL_IS_WIDGET (parent));
 
128
 
 
129
        panel = PANEL_WIDGET (parent);
120
130
 
121
131
        panel_widget_applet_drag_start (panel, info->widget,
122
132
                                        PW_DRAG_OFF_CENTER,
186
196
 
187
197
        locked = gconf_value_get_bool (value);
188
198
 
189
 
        panel_widget = PANEL_WIDGET (info->widget->parent);
 
199
        panel_widget = panel_applet_get_panel_widget (info);
190
200
        applet_locked = panel_widget_get_applet_locked (panel_widget,
191
201
                                                        info->widget);
192
202
 
195
205
 
196
206
        panel_applet_toggle_locked (info);
197
207
 
198
 
        if (info->type == PANEL_OBJECT_BONOBO)
 
208
        if (info->type == PANEL_OBJECT_APPLET)
199
209
                panel_applet_frame_sync_menu_state (PANEL_APPLET_FRAME (info->widget));
200
210
        else
201
211
                panel_applet_recreate_menu (info);
217
227
{
218
228
        PanelWidget *panel_widget;
219
229
 
220
 
        panel_widget = PANEL_WIDGET (menu->info->widget->parent);
 
230
        panel_widget = panel_applet_get_panel_widget (menu->info);
221
231
 
222
232
        return gtk_window_get_screen (GTK_WINDOW (panel_widget->toplevel));
223
233
}
269
279
                        PANEL_MENU_BAR (menu->info->widget), menu->name);
270
280
                break;
271
281
 
272
 
        case PANEL_OBJECT_BONOBO:
 
282
        case PANEL_OBJECT_APPLET:
273
283
                /*
274
284
                 * Applet's menu's are handled differently
275
285
                 */
288
298
{
289
299
        PanelWidget *panel_widget;
290
300
 
291
 
        panel_widget = PANEL_WIDGET (info->widget->parent);
 
301
        panel_widget = panel_applet_get_panel_widget (info);
292
302
 
293
303
        panel_toplevel_push_autohide_disabler (panel_widget->toplevel);
294
304
}
300
310
{
301
311
        PanelWidget *panel_widget;
302
312
 
303
 
        panel_widget = PANEL_WIDGET (info->widget->parent);
 
313
        panel_widget = panel_applet_get_panel_widget (info);
304
314
 
305
315
        panel_toplevel_pop_autohide_disabler (panel_widget->toplevel);
306
316
}
471
481
        PanelWidget *panel_widget;
472
482
        gboolean     added_anything = FALSE;
473
483
 
474
 
        panel_widget = PANEL_WIDGET (info->widget->parent);
 
484
        panel_widget = panel_applet_get_panel_widget (info);
475
485
 
476
486
        menu = g_object_ref_sink (gtk_menu_new ());
477
487
 
575
585
        children = gtk_container_get_children (GTK_CONTAINER (menu));
576
586
 
577
587
        for (l = children; l; l = l->next) {
578
 
                GtkWidget *submenu = GTK_MENU_ITEM (l->data)->submenu;
 
588
                GtkWidget *submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (l->data));
579
589
 
580
590
                if (submenu)
581
591
                        panel_applet_menu_set_recurse (
592
602
                            gboolean  *push_in,
593
603
                            GtkWidget *applet)
594
604
{
 
605
        GtkAllocation   allocation;
595
606
        GtkRequisition  requisition;
596
607
        GdkScreen      *screen;
 
608
        GtkWidget      *parent;
597
609
        int             menu_x = 0;
598
610
        int             menu_y = 0;
599
611
        int             pointer_x;
600
612
        int             pointer_y;
601
613
 
602
 
        g_return_if_fail (PANEL_IS_WIDGET (applet->parent));
 
614
        parent = gtk_widget_get_parent (applet);
 
615
 
 
616
        g_return_if_fail (PANEL_IS_WIDGET (parent));
603
617
 
604
618
        screen = gtk_widget_get_screen (applet);
605
619
 
606
620
        gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
607
621
 
608
 
        gdk_window_get_origin (applet->window, &menu_x, &menu_y);
 
622
        gdk_window_get_origin (gtk_widget_get_window (applet), &menu_x, &menu_y);
609
623
        gtk_widget_get_pointer (applet, &pointer_x, &pointer_y);
610
624
 
 
625
        gtk_widget_get_allocation (applet, &allocation);
 
626
 
611
627
        if (!gtk_widget_get_has_window (applet)) {
612
 
                menu_x += applet->allocation.x;
613
 
                menu_y += applet->allocation.y;
 
628
                menu_x += allocation.x;
 
629
                menu_y += allocation.y;
614
630
        }
615
631
 
616
 
        if (PANEL_WIDGET (applet->parent)->orient == GTK_ORIENTATION_HORIZONTAL) {
 
632
        if (PANEL_WIDGET (parent)->orient == GTK_ORIENTATION_HORIZONTAL) {
617
633
                if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) {
618
 
                        if (pointer_x < applet->allocation.width &&
 
634
                        if (pointer_x < allocation.width &&
619
635
                            requisition.width < pointer_x)
620
636
                                menu_x += MIN (pointer_x,
621
 
                                               applet->allocation.width - requisition.width);
 
637
                                               allocation.width - requisition.width);
622
638
                } else {
623
 
                        menu_x += applet->allocation.width - requisition.width;
624
 
                        if (pointer_x > 0 && pointer_x < applet->allocation.width &&
625
 
                            pointer_x < applet->allocation.width - requisition.width) {
626
 
                                menu_x -= MIN (applet->allocation.width - pointer_x,
627
 
                                               applet->allocation.width - requisition.width);
 
639
                        menu_x += allocation.width - requisition.width;
 
640
                        if (pointer_x > 0 && pointer_x < allocation.width &&
 
641
                            pointer_x < allocation.width - requisition.width) {
 
642
                                menu_x -= MIN (allocation.width - pointer_x,
 
643
                                               allocation.width - requisition.width);
628
644
                        }
629
645
                }
630
646
                menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width);
632
648
                if (menu_y > gdk_screen_get_height (screen) / 2)
633
649
                        menu_y -= requisition.height;
634
650
                else
635
 
                        menu_y += applet->allocation.height;
 
651
                        menu_y += allocation.height;
636
652
        } else {
637
 
                if (pointer_y < applet->allocation.height &&
 
653
                if (pointer_y < allocation.height &&
638
654
                    requisition.height < pointer_y)
639
 
                        menu_y += MIN (pointer_y, applet->allocation.height - requisition.height);
 
655
                        menu_y += MIN (pointer_y, allocation.height - requisition.height);
640
656
                menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height);
641
657
 
642
658
                if (menu_x > gdk_screen_get_width (screen) / 2)
643
659
                        menu_x -= requisition.width;
644
660
                else
645
 
                        menu_x += applet->allocation.width;
 
661
                        menu_x += allocation.width;
646
662
        }
647
663
 
648
664
        *x = menu_x;
658
674
 
659
675
        g_return_if_fail (info != NULL);
660
676
 
661
 
        panel_widget = PANEL_WIDGET (info->widget->parent);
 
677
        panel_widget = panel_applet_get_panel_widget (info);
662
678
 
663
679
        if (info->menu == NULL)
664
680
                info->menu = panel_applet_create_menu (info);
668
684
 
669
685
        panel_applet_menu_set_recurse (GTK_MENU (info->menu),
670
686
                                       "menu_panel",
671
 
                                       info->widget->parent);
 
687
                                       panel_widget);
672
688
 
673
689
        gtk_menu_set_screen (GTK_MENU (info->menu),
674
690
                             gtk_window_get_screen (GTK_WINDOW (panel_widget->toplevel)));
693
709
        if (panel_applet_is_in_drag ())
694
710
                return FALSE;
695
711
 
696
 
        if (info->type == PANEL_OBJECT_BONOBO)
 
712
        if (info->type == PANEL_OBJECT_APPLET)
697
713
                return FALSE;
698
714
 
699
715
        applet_show_menu (info, event);
755
771
                }
756
772
        }
757
773
 
758
 
        if (info->type != PANEL_OBJECT_BONOBO)
 
774
        if (info->type != PANEL_OBJECT_APPLET)
759
775
                panel_lockdown_notify_remove (G_CALLBACK (panel_applet_recreate_menu),
760
776
                                              info);
761
777
 
827
843
                if (strcmp (applet->id, id) == 0)
828
844
                        return TRUE;
829
845
        }
 
846
        for (li = panel_applets_loading; li != NULL; li = li->next) {
 
847
                PanelAppletToLoad *applet = li->data;
 
848
                if (strcmp (applet->id, id) == 0)
 
849
                        return TRUE;
 
850
        }
830
851
        return FALSE;
831
852
}
832
853
 
874
895
static gboolean
875
896
panel_applet_load_idle_handler (gpointer dummy)
876
897
{
 
898
        PanelObjectType    applet_type;
877
899
        PanelAppletToLoad *applet = NULL;
878
900
        PanelToplevel     *toplevel = NULL;
879
901
        PanelWidget       *panel_widget;
893
915
        }
894
916
 
895
917
        if (!l) {
896
 
                /* All the rest of the applets don't have a panel */
 
918
                /* All the remaining applets don't have a panel */
897
919
                for (l = panel_applets_to_load; l; l = l->next)
898
920
                        free_applet_to_load (l->data);
899
921
                g_slist_free (panel_applets_to_load);
920
942
                        applet->position = -1;
921
943
        }
922
944
 
923
 
        switch (applet->type) {
924
 
        case PANEL_OBJECT_BONOBO:
 
945
        /* We load applets asynchronously, so we specifically don't call
 
946
         * panel_applet_stop_loading() for this type. However, in case of
 
947
         * failure during the load, we might call panel_applet_stop_loading()
 
948
         * synchronously, which will make us lose the content of the applet
 
949
         * variable. So we save the type to be sure we always ignore the
 
950
         * applets. */
 
951
        applet_type = applet->type;
 
952
 
 
953
        switch (applet_type) {
 
954
        case PANEL_OBJECT_APPLET:
925
955
                panel_applet_frame_load_from_gconf (
926
956
                                        panel_widget,
927
957
                                        applet->locked,
984
1014
                break;
985
1015
        }
986
1016
 
987
 
        /* Only the bonobo applets will do a late stop_loading */
988
 
        if (applet->type != PANEL_OBJECT_BONOBO)
 
1017
        /* Only the real applets will do a late stop_loading */
 
1018
        if (applet_type != PANEL_OBJECT_APPLET)
989
1019
                panel_applet_stop_loading (applet->id);
990
1020
 
991
1021
        return TRUE;
1040
1070
                return;
1041
1071
        }
1042
1072
 
1043
 
        if (initial_load && panel_applets_to_load) {
 
1073
        if (panel_applets_to_load && panel_applet_unhide_toplevels_timeout == 0) {
1044
1074
                /* Install a timeout to make sure we don't block the
1045
1075
                 * unhiding because of an applet that doesn't load */
1046
1076
                panel_applet_unhide_toplevels_timeout =
1075
1105
        g_return_val_if_fail (applet != NULL, NULL);
1076
1106
        g_return_val_if_fail (GTK_IS_WIDGET (applet->widget), NULL);
1077
1107
 
1078
 
        panel_widget = PANEL_WIDGET (applet->widget->parent);
 
1108
        panel_widget = panel_applet_get_panel_widget (applet);
1079
1109
        if (!panel_widget)
1080
1110
                return NULL;
1081
1111
 
1137
1167
 
1138
1168
        client  = panel_gconf_get_client ();
1139
1169
 
1140
 
        key_type = applet_info->type == PANEL_OBJECT_BONOBO ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS;
 
1170
        key_type = applet_info->type == PANEL_OBJECT_APPLET ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS;
1141
1171
        
1142
 
        panel_widget = PANEL_WIDGET (applet_info->widget->parent);
 
1172
        panel_widget = panel_applet_get_panel_widget (applet_info);
1143
1173
 
1144
1174
        /* FIXME: Instead of getting keys, comparing and setting, there
1145
1175
           should be a dirty flag */
1196
1226
{
1197
1227
        if (!info)
1198
1228
                return NULL;
1199
 
        if (info->type != PANEL_OBJECT_BONOBO)
 
1229
        if (info->type != PANEL_OBJECT_APPLET)
1200
1230
                return NULL;
1201
1231
 
1202
1232
        PanelAppletFrame * frame = PANEL_APPLET_FRAME(info->data);
1329
1359
 
1330
1360
        g_object_set_data (G_OBJECT (applet), "applet_info", info);
1331
1361
 
1332
 
        if (type != PANEL_OBJECT_BONOBO)
 
1362
        if (type != PANEL_OBJECT_APPLET)
1333
1363
                panel_lockdown_notify_add (G_CALLBACK (panel_applet_recreate_menu),
1334
1364
                                           info);
1335
1365
 
1336
 
        key = panel_gconf_full_key ((type == PANEL_OBJECT_BONOBO) ?
 
1366
        key = panel_gconf_full_key ((type == PANEL_OBJECT_APPLET) ?
1337
1367
                                     PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS,
1338
1368
                                    id, "locked");
1339
1369
        panel_gconf_notify_add_while_alive (key,
1399
1429
        size_change (info, panel);
1400
1430
        back_change (info, panel);
1401
1431
 
1402
 
        if (type != PANEL_OBJECT_BONOBO)
 
1432
        if (type != PANEL_OBJECT_APPLET)
1403
1433
                gtk_widget_grab_focus (applet);
1404
1434
        else
1405
1435
                gtk_widget_child_focus (applet, GTK_DIR_TAB_FORWARD);
1433
1463
 
1434
1464
        client  = panel_gconf_get_client ();
1435
1465
        
1436
 
        key_type = (applet->type == PANEL_OBJECT_BONOBO) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS;
 
1466
        key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS;
1437
1467
       
1438
1468
        key = panel_gconf_full_key (key_type, applet->id, "position");
1439
1469
        if (!gconf_client_key_is_writable (client, key, NULL))
1462
1492
        
1463
1493
        client  = panel_gconf_get_client ();
1464
1494
        
1465
 
        key_type = (applet->type == PANEL_OBJECT_BONOBO) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS;
 
1495
        key_type = (applet->type == PANEL_OBJECT_APPLET) ? PANEL_GCONF_APPLETS : PANEL_GCONF_OBJECTS;
1466
1496
 
1467
1497
        key = panel_gconf_full_key (key_type, applet->id, "locked");
1468
1498