~ubuntu-branches/ubuntu/wily/xfce4-panel/wily

« back to all changes in this revision

Viewing changes to libxfce4panel/xfce-panel-plugin.c

  • Committer: Package Import Robot
  • Author(s): Unit 193, Unit 193, Lionel Le Folgoc
  • Date: 2014-02-12 15:41:39 UTC
  • mfrom: (1.1.36)
  • Revision ID: package-import@ubuntu.com-20140212154139-j4cm4hlso68qadjw
Tags: 4.11.0~0.git20140209.86a1b73-0ubuntu1
[ Unit 193 ]
* New git snapshot. (LP: #1238997)
* debian/patches:
  - 02_potfiles-fix-ftbfs.patch: added, add missing files to po/POTFILES.in.
* debian/control: add b-dep on newer garcon.

[ Lionel Le Folgoc ]
* debian/patches:
  - xubuntu_add-calendar-popup-to-clock-plugin.patch: dropped, included.
  - series: refreshed.
* debian/xfce4-panel.install: include both (gtk2 and gtk3) wrappers.
* debian/rules: pass --enable-gtk3 --disable-silent-rules to configure script.
* debian/control: add b-dep on libgtk-3-dev.
* debian/xfce4-panel.shlibs: updated for the gtk3 library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#endif
29
29
 
30
30
#include <gtk/gtk.h>
 
31
#if GTK_CHECK_VERSION (3, 0, 0)
 
32
#include <gtk/gtkx.h>
 
33
#endif
31
34
#include <glib.h>
32
35
#include <libxfce4util/libxfce4util.h>
33
36
 
131
134
  PROP_EXPAND,
132
135
  PROP_MODE,
133
136
  PROP_NROWS,
134
 
  PROP_SHRINK
 
137
  PROP_SHRINK,
 
138
  N_PROPERTIES
135
139
};
136
140
 
137
141
enum
195
199
 
196
200
 
197
201
 
198
 
static guint  plugin_signals[LAST_SIGNAL];
199
 
static GQuark item_properties = 0;
200
 
static GQuark item_about = 0;
 
202
static guint       plugin_signals[LAST_SIGNAL];
 
203
static GQuark      item_properties = 0;
 
204
static GQuark      item_about = 0;
 
205
static GParamSpec *plugin_props[N_PROPERTIES] = { NULL, };
201
206
 
202
207
 
203
208
 
463
468
   * xfce_panel_plugin_get_name() is recommended since that returns
464
469
   * a const string.
465
470
   **/
466
 
  g_object_class_install_property (gobject_class,
467
 
                                   PROP_NAME,
468
 
                                   g_param_spec_string ("name",
469
 
                                                        "Name",
470
 
                                                        "Plugin internal name",
471
 
                                                        NULL,
472
 
                                                        G_PARAM_READWRITE
473
 
                                                        | G_PARAM_STATIC_STRINGS
474
 
                                                        | G_PARAM_CONSTRUCT_ONLY));
 
471
  plugin_props[PROP_NAME] =
 
472
      g_param_spec_string ("name",
 
473
                           "Name",
 
474
                           "Plugin internal name",
 
475
                           NULL,
 
476
                           G_PARAM_READWRITE
 
477
                           | G_PARAM_STATIC_STRINGS
 
478
                           | G_PARAM_CONSTRUCT_ONLY);
475
479
 
476
480
  /**
477
481
   * XfcePanelPlugin:display-name:
481
485
   * it to read the plugin display name, but xfce_panel_plugin_get_display_name()
482
486
   * is recommended.
483
487
   **/
484
 
  g_object_class_install_property (gobject_class,
485
 
                                   PROP_DISPLAY_NAME,
486
 
                                   g_param_spec_string ("display-name",
487
 
                                                        "Display Name",
488
 
                                                        "Plugin display name",
489
 
                                                        NULL,
490
 
                                                        G_PARAM_READWRITE
491
 
                                                        | G_PARAM_STATIC_STRINGS
492
 
                                                        | G_PARAM_CONSTRUCT_ONLY));
 
488
  plugin_props[PROP_DISPLAY_NAME] =
 
489
      g_param_spec_string ("display-name",
 
490
                           "Display Name",
 
491
                           "Plugin display name",
 
492
                           NULL,
 
493
                           G_PARAM_READWRITE
 
494
                           | G_PARAM_STATIC_STRINGS
 
495
                           | G_PARAM_CONSTRUCT_ONLY);
493
496
 
494
497
  /**
495
498
   * XfcePanelPlugin:comment:
501
504
   *
502
505
   * Since: 4.8
503
506
   **/
504
 
  g_object_class_install_property (gobject_class,
505
 
                                   PROP_COMMENT,
506
 
                                   g_param_spec_string ("comment",
507
 
                                                        "Comment",
508
 
                                                        "Plugin comment",
509
 
                                                        NULL,
510
 
                                                        G_PARAM_READWRITE
511
 
                                                        | G_PARAM_STATIC_STRINGS
512
 
                                                        | G_PARAM_CONSTRUCT_ONLY));
 
507
  plugin_props[PROP_COMMENT] =
 
508
      g_param_spec_string ("comment",
 
509
                           "Comment",
 
510
                           "Plugin comment",
 
511
                           NULL,
 
512
                           G_PARAM_READWRITE
 
513
                           | G_PARAM_STATIC_STRINGS
 
514
                           | G_PARAM_CONSTRUCT_ONLY);
513
515
 
514
516
  /**
515
517
   * XfcePanelPlugin:id:
520
522
   *
521
523
   * Since: 4.8
522
524
   **/
523
 
  g_object_class_install_property (gobject_class,
524
 
                                   PROP_UNIQUE_ID,
525
 
                                   g_param_spec_int ("unique-id",
526
 
                                                     "Unique ID",
527
 
                                                     "Unique plugin ID",
528
 
                                                     -1, G_MAXINT, -1,
529
 
                                                     G_PARAM_READWRITE
530
 
                                                     | G_PARAM_STATIC_STRINGS
531
 
                                                     | G_PARAM_CONSTRUCT_ONLY));
 
525
  plugin_props[PROP_UNIQUE_ID] =
 
526
      g_param_spec_int ("unique-id",
 
527
                        "Unique ID",
 
528
                        "Unique plugin ID",
 
529
                        -1, G_MAXINT, -1,
 
530
                        G_PARAM_READWRITE
 
531
                        | G_PARAM_STATIC_STRINGS
 
532
                        | G_PARAM_CONSTRUCT_ONLY);
532
533
 
533
534
  /**
534
535
   * XfcePanelPlugin:arguments:
538
539
   * use it to read the arguments array, but
539
540
   * xfce_panel_plugin_get_arguments() is recommended.
540
541
   **/
541
 
  g_object_class_install_property (gobject_class,
542
 
                                   PROP_ARGUMENTS,
543
 
                                   g_param_spec_boxed ("arguments",
544
 
                                                       "Arguments",
545
 
                                                       "Startup arguments for the plugin",
546
 
                                                       G_TYPE_STRV,
547
 
                                                       G_PARAM_READWRITE
548
 
                                                       | G_PARAM_STATIC_STRINGS
549
 
                                                       | G_PARAM_CONSTRUCT_ONLY));
 
542
  plugin_props[PROP_ARGUMENTS] =
 
543
      g_param_spec_boxed ("arguments",
 
544
                          "Arguments",
 
545
                          "Startup arguments for the plugin",
 
546
                          G_TYPE_STRV,
 
547
                          G_PARAM_READWRITE
 
548
                          | G_PARAM_STATIC_STRINGS
 
549
                          | G_PARAM_CONSTRUCT_ONLY);
550
550
 
551
551
  /**
552
552
   * XfcePanelPlugin:orientation:
554
554
   * The #GtkOrientation of the #XfcePanelPlugin. Plugin writer can use it to read the
555
555
   * plugin orientation, but xfce_panel_plugin_get_orientation() is recommended.
556
556
   **/
557
 
  g_object_class_install_property (gobject_class,
558
 
                                   PROP_ORIENTATION,
559
 
                                   g_param_spec_enum ("orientation",
560
 
                                                      "Orientation",
561
 
                                                      "Orientation of the plugin's panel",
562
 
                                                      GTK_TYPE_ORIENTATION,
563
 
                                                      GTK_ORIENTATION_HORIZONTAL,
564
 
                                                      G_PARAM_READABLE
565
 
                                                      | G_PARAM_STATIC_STRINGS));
 
557
  plugin_props[PROP_ORIENTATION] =
 
558
      g_param_spec_enum ("orientation",
 
559
                         "Orientation",
 
560
                         "Orientation of the plugin's panel",
 
561
                         GTK_TYPE_ORIENTATION,
 
562
                         GTK_ORIENTATION_HORIZONTAL,
 
563
                         G_PARAM_READABLE
 
564
                         | G_PARAM_STATIC_STRINGS);
566
565
 
567
566
  /**
568
567
   * XfcePanelPlugin:size:
570
569
   * The size in pixels of the #XfcePanelPlugin. Plugin writer can use it to read the
571
570
   * plugin size, but xfce_panel_plugin_get_size() is recommended.
572
571
   **/
573
 
  g_object_class_install_property (gobject_class,
574
 
                                   PROP_SIZE,
575
 
                                   g_param_spec_int ("size",
576
 
                                                     "Size",
577
 
                                                     "Size of the plugin's panel",
578
 
                                                     0, (128 * 6), 0,
579
 
                                                     G_PARAM_READABLE
580
 
                                                     | G_PARAM_STATIC_STRINGS));
 
572
  plugin_props[PROP_SIZE] =
 
573
      g_param_spec_int ("size",
 
574
                        "Size",
 
575
                        "Size of the plugin's panel",
 
576
                        0, (128 * 6), 0,
 
577
                        G_PARAM_READABLE
 
578
                        | G_PARAM_STATIC_STRINGS);
581
579
 
582
580
  /**
583
581
   * XfcePanelPlugin:screen-position:
586
584
   * to read the plugin's screen position, but xfce_panel_plugin_get_screen_psotion()
587
585
   * is recommended.
588
586
   **/
589
 
  g_object_class_install_property (gobject_class,
590
 
                                   PROP_SCREEN_POSITION,
591
 
                                   g_param_spec_enum  ("screen-position",
592
 
                                                       "Screen Position",
593
 
                                                       "Screen position of the plugin's panel",
594
 
                                                       XFCE_TYPE_SCREEN_POSITION,
595
 
                                                       XFCE_SCREEN_POSITION_NONE,
596
 
                                                       G_PARAM_READABLE
597
 
                                                       | G_PARAM_STATIC_STRINGS));
 
587
  plugin_props[PROP_SCREEN_POSITION] =
 
588
      g_param_spec_enum  ("screen-position",
 
589
                          "Screen Position",
 
590
                          "Screen position of the plugin's panel",
 
591
                          XFCE_TYPE_SCREEN_POSITION,
 
592
                          XFCE_SCREEN_POSITION_NONE,
 
593
                          G_PARAM_READABLE
 
594
                          | G_PARAM_STATIC_STRINGS);
598
595
 
599
596
  /**
600
597
   * XfcePanelPlugin:small:
605
602
   *
606
603
   * Since: 4.10
607
604
   **/
608
 
  g_object_class_install_property (gobject_class,
609
 
                                   PROP_SMALL,
610
 
                                   g_param_spec_boolean ("small",
611
 
                                                         "Small",
612
 
                                                         "Is this plugin small, e.g. a single button?",
613
 
                                                         FALSE,
614
 
                                                         G_PARAM_READWRITE
615
 
                                                         | G_PARAM_STATIC_STRINGS));
 
605
  plugin_props[PROP_SMALL] =
 
606
      g_param_spec_boolean ("small",
 
607
                            "Small",
 
608
                            "Is this plugin small, e.g. a single button?",
 
609
                            FALSE,
 
610
                            G_PARAM_READWRITE
 
611
                            | G_PARAM_STATIC_STRINGS);
616
612
 
617
613
  /**
618
614
   * XfcePanelPlugin:expand:
621
617
   * to read or set this property, but xfce_panel_plugin_set_expand()
622
618
   * is recommended.
623
619
   **/
624
 
  g_object_class_install_property (gobject_class,
625
 
                                   PROP_EXPAND,
626
 
                                   g_param_spec_boolean ("expand",
627
 
                                                         "Expand",
628
 
                                                         "Whether this plugin is expanded",
629
 
                                                         FALSE,
630
 
                                                         G_PARAM_READWRITE
631
 
                                                         | G_PARAM_STATIC_STRINGS));
 
620
  plugin_props[PROP_EXPAND] =
 
621
      g_param_spec_boolean ("expand",
 
622
                            "Expand",
 
623
                            "Whether this plugin is expanded",
 
624
                            FALSE,
 
625
                            G_PARAM_READWRITE
 
626
                            | G_PARAM_STATIC_STRINGS);
632
627
 
633
628
  /**
634
629
   * XfcePanelPlugin:shrink:
639
634
   *
640
635
   * Since: 4.10
641
636
   **/
642
 
  g_object_class_install_property (gobject_class,
643
 
                                   PROP_SHRINK,
644
 
                                   g_param_spec_boolean ("shrink",
645
 
                                                         "Shrink",
646
 
                                                         "Whether this plugin can shrink",
647
 
                                                         FALSE,
648
 
                                                         G_PARAM_READWRITE
649
 
                                                         | G_PARAM_STATIC_STRINGS));
 
637
  plugin_props[PROP_SHRINK] =
 
638
      g_param_spec_boolean ("shrink",
 
639
                            "Shrink",
 
640
                            "Whether this plugin can shrink",
 
641
                            FALSE,
 
642
                            G_PARAM_READWRITE
 
643
                            | G_PARAM_STATIC_STRINGS);
650
644
 
651
645
  /**
652
646
   * XfcePanelPlugin:mode:
655
649
   *
656
650
   * Since: 4.10
657
651
   **/
658
 
  g_object_class_install_property (gobject_class,
659
 
                                   PROP_MODE,
660
 
                                   g_param_spec_enum ("mode",
661
 
                                                      "Mode",
662
 
                                                      "Disply mode of the plugin",
663
 
                                                      XFCE_TYPE_PANEL_PLUGIN_MODE,
664
 
                                                      XFCE_PANEL_PLUGIN_MODE_HORIZONTAL,
665
 
                                                      G_PARAM_READABLE
666
 
                                                      | G_PARAM_STATIC_STRINGS));
 
652
  plugin_props[PROP_MODE] =
 
653
      g_param_spec_enum ("mode",
 
654
                         "Mode",
 
655
                         "Disply mode of the plugin",
 
656
                         XFCE_TYPE_PANEL_PLUGIN_MODE,
 
657
                         XFCE_PANEL_PLUGIN_MODE_HORIZONTAL,
 
658
                         G_PARAM_READABLE
 
659
                         | G_PARAM_STATIC_STRINGS);
667
660
 
668
661
  /**
669
662
   * XfcePanelPlugin:nrows:
672
665
   *
673
666
   * Since: 4.10
674
667
   **/
675
 
  g_object_class_install_property (gobject_class,
676
 
                                   PROP_NROWS,
677
 
                                   g_param_spec_uint ("nrows",
678
 
                                                      "Nrows",
679
 
                                                      "Number of rows of the panel",
680
 
                                                      1, 6, 1,
681
 
                                                      G_PARAM_READABLE
682
 
                                                      | G_PARAM_STATIC_STRINGS));
 
668
  plugin_props[PROP_NROWS] =
 
669
      g_param_spec_uint ("nrows",
 
670
                         "Nrows",
 
671
                         "Number of rows of the panel",
 
672
                         1, 6, 1,
 
673
                         G_PARAM_READABLE
 
674
                         | G_PARAM_STATIC_STRINGS);
 
675
 
 
676
  /* install all properties */
 
677
  g_object_class_install_properties (gobject_class, N_PROPERTIES, plugin_props);
683
678
 
684
679
  item_properties = g_quark_from_static_string ("item-properties");
685
680
  item_about = g_quark_from_static_string ("item-about");
1376
1371
      if (!handled)
1377
1372
        gtk_widget_set_size_request (GTK_WIDGET (plugin), real_size, real_size);
1378
1373
 
1379
 
      g_object_notify (G_OBJECT (plugin), "size");
 
1374
      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_SIZE]);
1380
1375
    }
1381
1376
}
1382
1377
 
1402
1397
      g_signal_emit (G_OBJECT (plugin),
1403
1398
                     plugin_signals[MODE_CHANGED], 0, mode);
1404
1399
 
1405
 
      g_object_notify (G_OBJECT (plugin), "mode");
 
1400
      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_MODE]);
1406
1401
 
1407
1402
      /* emit old orientation property for compatibility */
1408
1403
      new_orientation = xfce_panel_plugin_get_orientation (plugin);
1411
1406
          g_signal_emit (G_OBJECT (plugin),
1412
1407
                         plugin_signals[ORIENTATION_CHANGED], 0, new_orientation);
1413
1408
 
1414
 
          g_object_notify (G_OBJECT (plugin), "orientation");
 
1409
          g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_ORIENTATION]);
1415
1410
        }
1416
1411
    }
1417
1412
}
1436
1431
      g_signal_emit (G_OBJECT (plugin),
1437
1432
                     plugin_signals[NROWS_CHANGED], 0, nrows);
1438
1433
 
1439
 
      g_object_notify (G_OBJECT (plugin), "nrows");
 
1434
      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_NROWS]);
1440
1435
 
1441
1436
      /* also the size changed */
1442
1437
      xfce_panel_plugin_set_size (provider, -1);
1463
1458
                     plugin_signals[SCREEN_POSITION_CHANGED], 0,
1464
1459
                     screen_position);
1465
1460
 
1466
 
      g_object_notify (G_OBJECT (plugin), "screen-position");
 
1461
      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_SCREEN_POSITION]);
1467
1462
    }
1468
1463
}
1469
1464
 
1844
1839
                                              expand ? PROVIDER_SIGNAL_EXPAND_PLUGIN :
1845
1840
                                                  PROVIDER_SIGNAL_COLLAPSE_PLUGIN);
1846
1841
 
1847
 
      g_object_notify (G_OBJECT (plugin), "expand");
 
1842
      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_EXPAND]);
1848
1843
    }
1849
1844
}
1850
1845
 
1902
1897
                                              shrink ? PROVIDER_SIGNAL_SHRINK_PLUGIN :
1903
1898
                                                  PROVIDER_SIGNAL_UNSHRINK_PLUGIN);
1904
1899
 
1905
 
      g_object_notify (G_OBJECT (plugin), "shrink");
 
1900
      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_SHRINK]);
1906
1901
    }
1907
1902
}
1908
1903
 
1958
1953
                                              small ? PROVIDER_SIGNAL_SMALL_PLUGIN :
1959
1954
                                              PROVIDER_SIGNAL_UNSMALL_PLUGIN);
1960
1955
 
1961
 
      g_object_notify (G_OBJECT (plugin), "small");
 
1956
      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_SMALL]);
1962
1957
    }
1963
1958
}
1964
1959
 
2417
2412
  GTimeVal        now_t, end_t;
2418
2413
  GtkWidget      *toplevel, *plug;
2419
2414
  gint            px, py;
 
2415
  GtkAllocation   alloc;
2420
2416
 
2421
2417
  g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
2422
2418
  g_return_if_fail (GTK_IS_WIDGET (menu_widget));
2428
2424
    attach_widget = GTK_WIDGET (plugin);
2429
2425
 
2430
2426
  /* make sure the menu is realized to get valid rectangle sizes */
2431
 
  if (!GTK_WIDGET_REALIZED (menu_widget))
 
2427
  if (!gtk_widget_get_realized (menu_widget))
2432
2428
    gtk_widget_realize (menu_widget);
2433
2429
 
2434
2430
  /* make sure the attach widget is realized for the gdkwindow */
2435
 
  if (!GTK_WIDGET_REALIZED (attach_widget))
 
2431
  if (!gtk_widget_get_realized (attach_widget))
2436
2432
    gtk_widget_realize (attach_widget);
2437
2433
 
2438
2434
  /* get the menu/widget size request */
 
2435
#if GTK_CHECK_VERSION (3, 0, 0)
 
2436
  gtk_widget_get_preferred_size (menu_widget, &requisition, NULL);
 
2437
#else
2439
2438
  gtk_widget_size_request (menu_widget, &requisition);
 
2439
#endif
2440
2440
 
2441
2441
  /* get the root position of the attach widget */
2442
2442
  toplevel = gtk_widget_get_toplevel (attach_widget);
2446
2446
  plug = gtk_widget_get_ancestor (attach_widget, GTK_TYPE_PLUG);
2447
2447
  if (plug != NULL)
2448
2448
    {
 
2449
#if GTK_CHECK_VERSION (3, 0, 0)
 
2450
       gdk_window_get_geometry (gtk_plug_get_socket_window (GTK_PLUG (plug)),
 
2451
                                &px, &py, NULL, NULL);
 
2452
#else
2449
2453
       gdk_window_get_geometry (gtk_plug_get_socket_window (GTK_PLUG (plug)),
2450
2454
                                &px, &py, NULL, NULL, NULL);
 
2455
#endif
2451
2456
 
2452
2457
       *x += px;
2453
2458
       *y += py;
2466
2471
          while (gtk_events_pending ())
2467
2472
            gtk_main_iteration ();
2468
2473
 
2469
 
          gdk_window_get_position (GDK_WINDOW (attach_widget->window), x, y);
 
2474
          gdk_window_get_position (gtk_widget_get_window (attach_widget), x, y);
2470
2475
 
2471
2476
          /* don't try longer then 1/2 a second */
2472
2477
          g_get_current_time (&now_t);
2478
2483
    }
2479
2484
 
2480
2485
  /* add the widgets allocation */
2481
 
  *x += attach_widget->allocation.x;
2482
 
  *y += attach_widget->allocation.y;
 
2486
  gtk_widget_get_allocation (attach_widget, &alloc);
 
2487
  *x += alloc.x;
 
2488
  *y += alloc.y;
2483
2489
 
2484
2490
  switch (xfce_panel_plugin_arrow_type (plugin))
2485
2491
    {
2488
2494
      break;
2489
2495
 
2490
2496
    case GTK_ARROW_DOWN:
2491
 
      *y += attach_widget->allocation.height;
 
2497
      *y += alloc.height;
2492
2498
      break;
2493
2499
 
2494
2500
    case GTK_ARROW_LEFT:
2496
2502
      break;
2497
2503
 
2498
2504
    default: /* GTK_ARROW_RIGHT and GTK_ARROW_NONE */
2499
 
      *x += attach_widget->allocation.width;
 
2505
      *x += alloc.width;
2500
2506
      break;
2501
2507
    }
2502
2508
 
2503
2509
  /* get the monitor geometry */
2504
2510
  screen = gtk_widget_get_screen (attach_widget);
2505
 
  monitor_num = gdk_screen_get_monitor_at_window (screen, attach_widget->window);
 
2511
  monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (attach_widget));
2506
2512
  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
2507
2513
 
2508
2514
  /* keep the menu inside the screen */
2580
2586
  xfce_panel_plugin_position_widget (XFCE_PANEL_PLUGIN (panel_plugin),
2581
2587
                                     GTK_WIDGET (menu), attach_widget, x, y);
2582
2588
 
 
2589
#if GTK_CHECK_VERSION (3, 0, 0)
 
2590
  /* FIXME */
 
2591
  /* A workaround for Gtk3 popup menus with scroll buttons */
 
2592
  /* Menus are "pushed in" anyway */
 
2593
  *push_in = FALSE;
 
2594
#else
2583
2595
  /* keep the menu inside screen */
2584
2596
  *push_in = TRUE;
 
2597
#endif
2585
2598
}
2586
2599
 
2587
2600