summaryrefslogtreecommitdiff
path: root/libmate-panel-applet/mate-panel-applet.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmate-panel-applet/mate-panel-applet.c')
-rw-r--r--libmate-panel-applet/mate-panel-applet.c771
1 files changed, 444 insertions, 327 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c
index ce482c6e..3d6a4ac1 100644
--- a/libmate-panel-applet/mate-panel-applet.c
+++ b/libmate-panel-applet/mate-panel-applet.c
@@ -51,7 +51,7 @@
#include "mate-panel-applet-marshal.h"
#include "mate-panel-applet-enums.h"
-struct _MatePanelAppletPrivate {
+typedef struct {
GtkWidget *plug;
GDBusConnection *connection;
@@ -82,7 +82,7 @@ struct _MatePanelAppletPrivate {
gboolean locked;
gboolean locked_down;
-};
+} MatePanelAppletPrivate;
enum {
CHANGE_ORIENT,
@@ -158,28 +158,33 @@ G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_B
char *
mate_panel_applet_get_preferences_path (MatePanelApplet *applet)
{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+ MatePanelAppletPrivate *priv;
+
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL);
- if (!applet->priv->prefs_path)
+ priv = mate_panel_applet_get_instance_private (applet);
+ if (!priv->prefs_path)
return NULL;
- return g_strdup (applet->priv->prefs_path);
+ return g_strdup (priv->prefs_path);
}
static void
mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
const char *prefs_path)
{
- if (applet->priv->prefs_path == prefs_path)
- return;
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (applet);
- if (g_strcmp0 (applet->priv->prefs_path, prefs_path) == 0)
+ if (priv->prefs_path == prefs_path)
return;
- if (prefs_path) {
- applet->priv->prefs_path = g_strdup (prefs_path);
+ if (g_strcmp0 (priv->prefs_path, prefs_path) == 0)
+ return;
- }
+ if (prefs_path)
+ priv->prefs_path = g_strdup (prefs_path);
g_object_notify (G_OBJECT (applet), "prefs-path");
}
@@ -187,25 +192,33 @@ mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
MatePanelAppletFlags
mate_panel_applet_get_flags (MatePanelApplet *applet)
{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE);
+ MatePanelAppletPrivate *priv;
+
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE);
+
+ priv = mate_panel_applet_get_instance_private (applet);
- return applet->priv->flags;
+ return priv->flags;
}
void
mate_panel_applet_set_flags (MatePanelApplet *applet,
MatePanelAppletFlags flags)
{
- g_return_if_fail (PANEL_IS_APPLET (applet));
+ MatePanelAppletPrivate *priv;
- if (applet->priv->flags == flags)
+ g_return_if_fail (MATE_PANEL_IS_APPLET (applet));
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->flags == flags)
return;
- applet->priv->flags = flags;
+ priv->flags = flags;
g_object_notify (G_OBJECT (applet), "flags");
- if (applet->priv->connection) {
+ if (priv->connection) {
GVariantBuilder builder;
GVariantBuilder invalidated_builder;
GError *error = NULL;
@@ -214,18 +227,18 @@ mate_panel_applet_set_flags (MatePanelApplet *applet,
g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
g_variant_builder_add (&builder, "{sv}", "Flags",
- g_variant_new_uint32 (applet->priv->flags));
-
- g_dbus_connection_emit_signal (applet->priv->connection,
- NULL,
- applet->priv->object_path,
- "org.freedesktop.DBus.Properties",
- "PropertiesChanged",
- g_variant_new ("(sa{sv}as)",
- MATE_PANEL_APPLET_INTERFACE,
- &builder,
- &invalidated_builder),
- &error);
+ g_variant_new_uint32 (priv->flags));
+
+ g_dbus_connection_emit_signal (priv->connection,
+ NULL,
+ priv->object_path,
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ g_variant_new ("(sa{sv}as)",
+ MATE_PANEL_APPLET_INTERFACE,
+ &builder,
+ &invalidated_builder),
+ &error);
if (error) {
g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
error->message);
@@ -240,13 +253,16 @@ static void
mate_panel_applet_size_hints_ensure (MatePanelApplet *applet,
int new_size)
{
- if (applet->priv->size_hints && applet->priv->size_hints_len < new_size) {
- g_free (applet->priv->size_hints);
- applet->priv->size_hints = g_new (gint, new_size);
- } else if (!applet->priv->size_hints) {
- applet->priv->size_hints = g_new (gint, new_size);
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (applet);
+ if (priv->size_hints && priv->size_hints_len < new_size) {
+ g_free (priv->size_hints);
+ priv->size_hints = g_new (gint, new_size);
+ } else if (!priv->size_hints) {
+ priv->size_hints = g_new (gint, new_size);
}
- applet->priv->size_hints_len = new_size;
+ priv->size_hints_len = new_size;
}
static gboolean
@@ -255,16 +271,19 @@ mate_panel_applet_size_hints_changed (MatePanelApplet *applet,
int n_elements,
int base_size)
{
+ MatePanelAppletPrivate *priv;
gint i;
- if (!applet->priv->size_hints)
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (!priv->size_hints)
return TRUE;
- if (applet->priv->size_hints_len != n_elements)
+ if (priv->size_hints_len != n_elements)
return TRUE;
for (i = 0; i < n_elements; i++) {
- if (size_hints[i] + base_size != applet->priv->size_hints[i])
+ if (size_hints[i] + base_size != priv->size_hints[i])
return TRUE;
}
@@ -284,19 +303,22 @@ mate_panel_applet_set_size_hints (MatePanelApplet *applet,
int n_elements,
int base_size)
{
+ MatePanelAppletPrivate *priv;
gint i;
/* Make sure property has really changed to avoid bus traffic */
if (!mate_panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
return;
+ priv = mate_panel_applet_get_instance_private (applet);
+
mate_panel_applet_size_hints_ensure (applet, n_elements);
for (i = 0; i < n_elements; i++)
- applet->priv->size_hints[i] = size_hints[i] + base_size;
+ priv->size_hints[i] = size_hints[i] + base_size;
g_object_notify (G_OBJECT (applet), "size-hints");
- if (applet->priv->connection) {
+ if (priv->connection) {
GVariantBuilder builder;
GVariantBuilder invalidated_builder;
GVariant **children;
@@ -305,24 +327,24 @@ mate_panel_applet_set_size_hints (MatePanelApplet *applet,
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
- children = g_new (GVariant *, applet->priv->size_hints_len);
+ children = g_new (GVariant *, priv->size_hints_len);
for (i = 0; i < n_elements; i++)
- children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
+ children[i] = g_variant_new_int32 (priv->size_hints[i]);
g_variant_builder_add (&builder, "{sv}", "SizeHints",
- g_variant_new_array (G_VARIANT_TYPE_INT32,
- children, applet->priv->size_hints_len));
+ g_variant_new_array (G_VARIANT_TYPE_INT32,
+ children, priv->size_hints_len));
g_free (children);
- g_dbus_connection_emit_signal (applet->priv->connection,
- NULL,
- applet->priv->object_path,
- "org.freedesktop.DBus.Properties",
- "PropertiesChanged",
- g_variant_new ("(sa{sv}as)",
- MATE_PANEL_APPLET_INTERFACE,
- &builder,
- &invalidated_builder),
- &error);
+ g_dbus_connection_emit_signal (priv->connection,
+ NULL,
+ priv->object_path,
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ g_variant_new ("(sa{sv}as)",
+ MATE_PANEL_APPLET_INTERFACE,
+ &builder,
+ &invalidated_builder),
+ &error);
if (error) {
g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
error->message);
@@ -336,9 +358,13 @@ mate_panel_applet_set_size_hints (MatePanelApplet *applet,
guint
mate_panel_applet_get_size (MatePanelApplet *applet)
{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), 0);
+ MatePanelAppletPrivate *priv;
+
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0);
+
+ priv = mate_panel_applet_get_instance_private (applet);
- return applet->priv->size;
+ return priv->size;
}
/* Applets cannot set their size, so API is not public. */
@@ -346,12 +372,16 @@ static void
mate_panel_applet_set_size (MatePanelApplet *applet,
guint size)
{
- g_return_if_fail (PANEL_IS_APPLET (applet));
+ MatePanelAppletPrivate *priv;
- if (applet->priv->size == size)
+ g_return_if_fail (MATE_PANEL_IS_APPLET (applet));
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->size == size)
return;
- applet->priv->size = size;
+ priv->size = size;
g_signal_emit (G_OBJECT (applet),
mate_panel_applet_signals [CHANGE_SIZE],
0, size);
@@ -362,9 +392,13 @@ mate_panel_applet_set_size (MatePanelApplet *applet,
MatePanelAppletOrient
mate_panel_applet_get_orient (MatePanelApplet *applet)
{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), 0);
+ MatePanelAppletPrivate *priv;
+
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0);
+
+ priv = mate_panel_applet_get_instance_private (applet);
- return applet->priv->orient;
+ return priv->orient;
}
/* Applets cannot set their orientation, so API is not public. */
@@ -372,12 +406,16 @@ static void
mate_panel_applet_set_orient (MatePanelApplet *applet,
MatePanelAppletOrient orient)
{
- g_return_if_fail (PANEL_IS_APPLET (applet));
+ MatePanelAppletPrivate *priv;
- if (applet->priv->orient == orient)
+ g_return_if_fail (MATE_PANEL_IS_APPLET (applet));
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->orient == orient)
return;
- applet->priv->orient = orient;
+ priv->orient = orient;
g_signal_emit (G_OBJECT (applet),
mate_panel_applet_signals [CHANGE_ORIENT],
0, orient);
@@ -389,14 +427,17 @@ static void
mate_panel_applet_set_locked (MatePanelApplet *applet,
gboolean locked)
{
+ MatePanelAppletPrivate *priv;
GtkAction *action;
- g_return_if_fail (PANEL_IS_APPLET (applet));
+ g_return_if_fail (MATE_PANEL_IS_APPLET (applet));
- if (applet->priv->locked == locked)
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->locked == locked)
return;
- applet->priv->locked = locked;
+ priv->locked = locked;
action = mate_panel_applet_menu_get_action (applet, "Lock");
g_signal_handlers_block_by_func (action,
@@ -411,15 +452,15 @@ mate_panel_applet_set_locked (MatePanelApplet *applet,
g_object_notify (G_OBJECT (applet), "locked");
- if (applet->priv->connection) {
+ if (priv->connection) {
GError *error = NULL;
- g_dbus_connection_emit_signal (applet->priv->connection,
- NULL,
- applet->priv->object_path,
- MATE_PANEL_APPLET_INTERFACE,
- locked ? "Lock" : "Unlock",
- NULL, &error);
+ g_dbus_connection_emit_signal (priv->connection,
+ NULL,
+ priv->object_path,
+ MATE_PANEL_APPLET_INTERFACE,
+ locked ? "Lock" : "Unlock",
+ NULL, &error);
if (error) {
g_printerr ("Failed to send signal %s: %s\n",
locked ? "Lock" : "Unlock",
@@ -432,9 +473,13 @@ mate_panel_applet_set_locked (MatePanelApplet *applet,
gboolean
mate_panel_applet_get_locked_down (MatePanelApplet *applet)
{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);
+ MatePanelAppletPrivate *priv;
+
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), FALSE);
- return applet->priv->locked_down;
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ return priv->locked_down;
}
/* Applets cannot set the lockdown state, so API is not public. */
@@ -442,12 +487,16 @@ static void
mate_panel_applet_set_locked_down (MatePanelApplet *applet,
gboolean locked_down)
{
- g_return_if_fail (PANEL_IS_APPLET (applet));
+ MatePanelAppletPrivate *priv;
+
+ g_return_if_fail (MATE_PANEL_IS_APPLET (applet));
- if (applet->priv->locked_down == locked_down)
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->locked_down == locked_down)
return;
- applet->priv->locked_down = locked_down;
+ priv->locked_down = locked_down;
mate_panel_applet_menu_update_actions (applet);
g_object_notify (G_OBJECT (applet), "locked-down");
@@ -552,6 +601,7 @@ mate_panel_applet_request_focus (MatePanelApplet *applet,
guint32 timestamp)
{
#ifdef HAVE_X11
+ MatePanelAppletPrivate *priv;
GdkScreen *screen;
GdkWindow *root;
GdkDisplay *display;
@@ -563,9 +613,10 @@ mate_panel_applet_request_focus (MatePanelApplet *applet,
if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
return;
- g_return_if_fail (PANEL_IS_APPLET (applet));
+ g_return_if_fail (MATE_PANEL_IS_APPLET (applet));
- screen = gtk_window_get_screen (GTK_WINDOW (applet->priv->plug));
+ priv = mate_panel_applet_get_instance_private (applet);
+ screen = gtk_window_get_screen (GTK_WINDOW (priv->plug));
root = gdk_screen_get_root_window (screen);
display = gdk_screen_get_display (screen);
@@ -601,42 +652,50 @@ static GtkAction *
mate_panel_applet_menu_get_action (MatePanelApplet *applet,
const gchar *action)
{
- return gtk_action_group_get_action (applet->priv->panel_action_group, action);
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ return gtk_action_group_get_action (priv->panel_action_group, action);
}
static void
mate_panel_applet_menu_update_actions (MatePanelApplet *applet)
{
- gboolean locked = applet->priv->locked;
- gboolean locked_down = applet->priv->locked_down;
+ MatePanelAppletPrivate *priv;
+ priv = mate_panel_applet_get_instance_private (applet);
g_object_set (mate_panel_applet_menu_get_action (applet, "Lock"),
- "visible", !locked_down, NULL);
+ "visible", !priv->locked_down,
+ NULL);
g_object_set (mate_panel_applet_menu_get_action (applet, "Move"),
- "sensitive", !locked,
- "visible", !locked_down,
- NULL);
+ "sensitive", !priv->locked,
+ "visible", !priv->locked_down,
+ NULL);
g_object_set (mate_panel_applet_menu_get_action (applet, "Remove"),
- "sensitive", !locked,
- "visible", !locked_down,
- NULL);
+ "sensitive", !priv->locked,
+ "visible", !priv->locked_down,
+ NULL);
}
static void
mate_panel_applet_menu_cmd_remove (GtkAction *action,
MatePanelApplet *applet)
{
+ MatePanelAppletPrivate *priv;
GError *error = NULL;
- if (!applet->priv->connection)
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (!priv->connection)
return;
- g_dbus_connection_emit_signal (applet->priv->connection,
- NULL,
- applet->priv->object_path,
- MATE_PANEL_APPLET_INTERFACE,
- "RemoveFromPanel",
- NULL, &error);
+ g_dbus_connection_emit_signal (priv->connection,
+ NULL,
+ priv->object_path,
+ MATE_PANEL_APPLET_INTERFACE,
+ "RemoveFromPanel",
+ NULL, &error);
if (error) {
g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
error->message);
@@ -648,14 +707,17 @@ static void
mate_panel_applet_menu_cmd_move (GtkAction *action,
MatePanelApplet *applet)
{
- GError *error = NULL;
+ MatePanelAppletPrivate *priv;
+ GError *error = NULL;
+
+ priv = mate_panel_applet_get_instance_private (applet);
- if (!applet->priv->connection)
+ if (!priv->connection)
return;
- g_dbus_connection_emit_signal (applet->priv->connection,
+ g_dbus_connection_emit_signal (priv->connection,
NULL,
- applet->priv->object_path,
+ priv->object_path,
MATE_PANEL_APPLET_INTERFACE,
"Move",
NULL, &error);
@@ -681,25 +743,28 @@ mate_panel_applet_setup_menu (MatePanelApplet *applet,
const gchar *xml,
GtkActionGroup *applet_action_group)
{
+ MatePanelAppletPrivate *priv;
gchar *new_xml;
GError *error = NULL;
- g_return_if_fail (PANEL_IS_APPLET (applet));
+ g_return_if_fail (MATE_PANEL_IS_APPLET (applet));
g_return_if_fail (xml != NULL);
- if (applet->priv->applet_action_group)
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->applet_action_group)
return;
- applet->priv->applet_action_group = g_object_ref (applet_action_group);
- gtk_ui_manager_insert_action_group (applet->priv->ui_manager,
+ priv->applet_action_group = g_object_ref (applet_action_group);
+ gtk_ui_manager_insert_action_group (priv->ui_manager,
applet_action_group, 0);
new_xml = g_strdup_printf ("<ui><popup name=\"MatePanelAppletPopup\" action=\"AppletItems\">"
"<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
"</popup></ui>\n", xml);
- gtk_ui_manager_add_ui_from_string (applet->priv->ui_manager, new_xml, -1, &error);
+ gtk_ui_manager_add_ui_from_string (priv->ui_manager, new_xml, -1, &error);
g_free (new_xml);
- gtk_ui_manager_ensure_update (applet->priv->ui_manager);
+ gtk_ui_manager_ensure_update (priv->ui_manager);
if (error) {
g_warning ("Error merging menus: %s\n", error->message);
g_error_free (error);
@@ -767,46 +832,50 @@ mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
static void
mate_panel_applet_finalize (GObject *object)
{
- MatePanelApplet *applet = MATE_PANEL_APPLET (object);
+ MatePanelApplet *applet;
+ MatePanelAppletPrivate *priv;
- if (applet->priv->connection) {
- if (applet->priv->object_id)
- g_dbus_connection_unregister_object (applet->priv->connection,
- applet->priv->object_id);
- applet->priv->object_id = 0;
- g_object_unref (applet->priv->connection);
- applet->priv->connection = NULL;
+ applet = MATE_PANEL_APPLET (object);
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->connection) {
+ if (priv->object_id)
+ g_dbus_connection_unregister_object (priv->connection,
+ priv->object_id);
+ priv->object_id = 0;
+ g_object_unref (priv->connection);
+ priv->connection = NULL;
}
- if (applet->priv->object_path) {
- g_free (applet->priv->object_path);
- applet->priv->object_path = NULL;
+ if (priv->object_path) {
+ g_free (priv->object_path);
+ priv->object_path = NULL;
}
mate_panel_applet_set_preferences_path (applet, NULL);
- if (applet->priv->applet_action_group) {
- g_object_unref (applet->priv->applet_action_group);
- applet->priv->applet_action_group = NULL;
+ if (priv->applet_action_group) {
+ g_object_unref (priv->applet_action_group);
+ priv->applet_action_group = NULL;
}
- if (applet->priv->panel_action_group) {
- g_object_unref (applet->priv->panel_action_group);
- applet->priv->panel_action_group = NULL;
+ if (priv->panel_action_group) {
+ g_object_unref (priv->panel_action_group);
+ priv->panel_action_group = NULL;
}
- if (applet->priv->ui_manager) {
- g_object_unref (applet->priv->ui_manager);
- applet->priv->ui_manager = NULL;
+ if (priv->ui_manager) {
+ g_object_unref (priv->ui_manager);
+ priv->ui_manager = NULL;
}
- g_free (applet->priv->size_hints);
- g_free (applet->priv->prefs_path);
- g_free (applet->priv->background);
- g_free (applet->priv->id);
+ g_free (priv->size_hints);
+ g_free (priv->prefs_path);
+ g_free (priv->background);
+ g_free (priv->id);
/* closure is owned by the factory */
- applet->priv->closure = NULL;
+ priv->closure = NULL;
G_OBJECT_CLASS (mate_panel_applet_parent_class)->finalize (object);
}
@@ -839,10 +908,12 @@ static void
mate_panel_applet_menu_popup (MatePanelApplet *applet,
GdkEvent *event)
{
+ MatePanelAppletPrivate *priv;
GtkWidget *menu;
- menu = gtk_ui_manager_get_widget (applet->priv->ui_manager,
- "/MatePanelAppletPopup");
+ priv = mate_panel_applet_get_instance_private (applet);
+ menu = gtk_ui_manager_get_widget (priv->ui_manager,
+ "/MatePanelAppletPopup");
/* Set up theme and transparency support */
GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
@@ -857,7 +928,7 @@ mate_panel_applet_menu_popup (MatePanelApplet *applet,
gtk_style_context_add_class(context,"mate-panel-menu-bar");
GdkGravity widget_anchor = GDK_GRAVITY_NORTH_WEST;
GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST;
- switch (applet->priv->orient) {
+ switch (priv->orient) {
case MATE_PANEL_APPLET_ORIENT_UP:
menu_anchor = GDK_GRAVITY_SOUTH_WEST;
break;
@@ -888,7 +959,7 @@ mate_panel_applet_can_focus (GtkWidget *widget)
if (gtk_widget_get_has_tooltip (widget))
return TRUE;
- if (!PANEL_IS_APPLET (widget))
+ if (!MATE_PANEL_IS_APPLET (widget))
return FALSE;
return !container_has_focusable_child (GTK_CONTAINER (widget));
@@ -900,16 +971,19 @@ mate_panel_applet_button_event (MatePanelApplet *applet,
GdkEventButton *event)
{
#ifdef HAVE_X11
- GtkWidget *widget;
- GdkWindow *window;
- GdkWindow *socket_window;
- XEvent xevent;
- GdkDisplay *display;
+ MatePanelAppletPrivate *priv;
+ GtkWidget *widget;
+ GdkWindow *window;
+ GdkWindow *socket_window;
+ XEvent xevent;
+ GdkDisplay *display;
- if (!applet->priv->out_of_process)
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (!priv->out_of_process)
return FALSE;
- widget = applet->priv->plug;
+ widget = priv->plug;
if (!gtk_widget_is_toplevel (widget))
return FALSE;
@@ -1026,8 +1100,10 @@ mate_panel_applet_get_preferred_width (GtkWidget *widget,
natural_width);
#if !GTK_CHECK_VERSION (3, 23, 0)
- MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
- if (applet->priv->out_of_process) {
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
+ if (priv->out_of_process) {
/* Out-of-process applets end up scaled up doubly with GTK 3.22.
* For these builds divide by the scale factor to ensure
* they are back at their own intended size.
@@ -1050,8 +1126,10 @@ mate_panel_applet_get_preferred_height (GtkWidget *widget,
natural_height);
#if !GTK_CHECK_VERSION (3, 23, 0)
- MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
- if (applet->priv->out_of_process) {
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
+ if (priv->out_of_process) {
gint scale;
/* Out-of-process applets end up scaled up doubly with GTK 3.22.
* For these builds divide by the scale factor to ensure
@@ -1082,13 +1160,13 @@ static void
mate_panel_applet_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ MatePanelAppletPrivate *priv;
GtkAllocation child_allocation;
MatePanelApplet *applet;
if (!mate_panel_applet_can_focus (widget)) {
GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->size_allocate (widget, allocation);
} else {
-
int border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_set_allocation (widget, allocation);
@@ -1113,12 +1191,12 @@ mate_panel_applet_size_allocate (GtkWidget *widget,
}
applet = MATE_PANEL_APPLET (widget);
+ priv = mate_panel_applet_get_instance_private (applet);
- if (applet->priv->previous_height != allocation->height ||
- applet->priv->previous_width != allocation->width) {
- applet->priv->previous_height = allocation->height;
- applet->priv->previous_width = allocation->width;
-
+ if ((priv->previous_height != allocation->height) ||
+ (priv->previous_width != allocation->width)) {
+ priv->previous_height = allocation->height;
+ priv->previous_width = allocation->width;
mate_panel_applet_handle_background (applet);
}
}
@@ -1161,19 +1239,19 @@ static gboolean
mate_panel_applet_focus (GtkWidget *widget,
GtkDirectionType dir)
{
+ MatePanelAppletPrivate *priv;
gboolean ret;
GtkWidget *previous_focus_child;
- MatePanelApplet *applet;
- g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE);
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (widget), FALSE);
- applet = MATE_PANEL_APPLET (widget);
- if (applet->priv->moving_focus_out) {
+ priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
+ if (priv->moving_focus_out) {
/*
* Applet will retain focus if there is nothing else on the
* panel to get focus
*/
- applet->priv->moving_focus_out = FALSE;
+ priv->moving_focus_out = FALSE;
return FALSE;
}
@@ -1297,7 +1375,7 @@ mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet,
cairo_t *cr;
cairo_pattern_t *pattern;
- g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL);
if (!gtk_widget_get_realized (GTK_WIDGET (applet)))
return NULL;
@@ -1349,15 +1427,17 @@ mate_panel_applet_handle_background_string (MatePanelApplet *applet,
GdkRGBA *color,
cairo_pattern_t **pattern)
{
+ MatePanelAppletPrivate *priv;
MatePanelAppletBackgroundType retval;
char **elements;
+ priv = mate_panel_applet_get_instance_private (applet);
retval = PANEL_NO_BACKGROUND;
- if (!gtk_widget_get_realized (GTK_WIDGET (applet)) || !applet->priv->background)
+ if (!gtk_widget_get_realized (GTK_WIDGET (applet)) || !priv->background)
return retval;
- elements = g_strsplit (applet->priv->background, ":", -1);
+ elements = g_strsplit (priv->background, ":", -1);
if (elements [0] && !strcmp (elements [0], "none" )) {
retval = PANEL_NO_BACKGROUND;
@@ -1416,11 +1496,12 @@ mate_panel_applet_get_background (MatePanelApplet *applet,
GdkRGBA *color,
cairo_pattern_t **pattern)
{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND);
+ g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND);
/* initial sanity */
if (pattern != NULL)
*pattern = NULL;
+
if (color != NULL)
memset (color, 0, sizeof (GdkRGBA));
@@ -1431,15 +1512,18 @@ static void
mate_panel_applet_set_background_string (MatePanelApplet *applet,
const gchar *background)
{
- if (applet->priv->background == background)
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->background == background)
return;
- if (g_strcmp0 (applet->priv->background, background) == 0)
+ if (g_strcmp0 (priv->background, background) == 0)
return;
- if (applet->priv->background)
- g_free (applet->priv->background);
- applet->priv->background = background ? g_strdup (background) : NULL;
+ g_free (priv->background);
+ priv->background = background ? g_strdup (background) : NULL;
mate_panel_applet_handle_background (applet);
g_object_notify (G_OBJECT (applet), "background");
@@ -1489,24 +1573,31 @@ mate_panel_applet_handle_background (MatePanelApplet *applet)
static void
mate_panel_applet_realize (GtkWidget *widget)
{
+ MatePanelApplet *applet;
+ MatePanelAppletPrivate *priv;
+
GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->realize (widget);
- if (MATE_PANEL_APPLET (widget)->priv->background)
- mate_panel_applet_handle_background (MATE_PANEL_APPLET (widget));
+ applet = MATE_PANEL_APPLET (widget);
+ priv = mate_panel_applet_get_instance_private (applet);
+ if (priv->background)
+ mate_panel_applet_handle_background (applet);
}
static void
mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
GtkDirectionType dir)
{
- GtkWidget *toplevel;
+ MatePanelAppletPrivate *priv;
+ GtkWidget *toplevel;
- applet->priv->moving_focus_out = TRUE;
+ priv = mate_panel_applet_get_instance_private (applet);
+ priv->moving_focus_out = TRUE;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet));
g_return_if_fail (toplevel);
gtk_widget_child_focus (toplevel, dir);
- applet->priv->moving_focus_out = FALSE;
+ priv->moving_focus_out = FALSE;
}
static void
@@ -1515,35 +1606,38 @@ mate_panel_applet_change_background(MatePanelApplet *applet,
GdkRGBA* color,
cairo_pattern_t *pattern)
{
- GdkWindow *window;
+ MatePanelAppletPrivate *priv;
+ GdkWindow *window;
- if (applet->priv->out_of_process)
- window = gtk_widget_get_window (GTK_WIDGET (applet->priv->plug));
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ if (priv->out_of_process)
+ window = gtk_widget_get_window (GTK_WIDGET (priv->plug));
else
window = gtk_widget_get_window (GTK_WIDGET (applet));
- gtk_widget_set_app_paintable(GTK_WIDGET(applet),TRUE);
+ gtk_widget_set_app_paintable (GTK_WIDGET (applet),TRUE);
- if (applet->priv->out_of_process)
- _mate_panel_applet_apply_css(GTK_WIDGET(applet->priv->plug),type);
+ if (priv->out_of_process)
+ _mate_panel_applet_apply_css (GTK_WIDGET (priv->plug),type);
switch (type) {
case PANEL_NO_BACKGROUND:
- if (applet->priv->out_of_process){
+ if (priv->out_of_process){
pattern = cairo_pattern_create_rgba (0,0,0,0); /* Using NULL here breaks transparent */
gdk_window_set_background_pattern(window,pattern); /* backgrounds set by GTK theme */
}
break;
case PANEL_COLOR_BACKGROUND:
- if (applet->priv->out_of_process){
+ if (priv->out_of_process){
gdk_window_set_background_rgba(window,color);
- gtk_widget_queue_draw (applet->priv->plug); /*change the bg right away always */
+ gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
}
break;
case PANEL_PIXMAP_BACKGROUND:
- if (applet->priv->out_of_process){
+ if (priv->out_of_process){
gdk_window_set_background_pattern(window,pattern);
- gtk_widget_queue_draw (applet->priv->plug); /*change the bg right away always */
+ gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
}
break;
default:
@@ -1551,78 +1645,81 @@ mate_panel_applet_change_background(MatePanelApplet *applet,
break;
}
- if (applet->priv->out_of_process){
- GtkStyleContext *context =
- gtk_widget_get_style_context (GTK_WIDGET(applet->priv->plug));
+ if (priv->out_of_process){
+ GtkStyleContext *context;
- if (applet->priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
- applet->priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN){
- gtk_style_context_add_class(context,"horizontal");
- }
- else {
- gtk_style_context_add_class(context,"vertical");
- }
+ context = gtk_widget_get_style_context (GTK_WIDGET (priv->plug));
+
+ if (priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
+ priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN)
+ gtk_style_context_add_class (context, "horizontal");
+ else
+ gtk_style_context_add_class (context, "vertical");
}
}
static void
mate_panel_applet_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- MatePanelApplet *applet = MATE_PANEL_APPLET (object);
+ MatePanelApplet *applet;
+ MatePanelAppletPrivate *priv;
- switch (prop_id) {
- case PROP_OUT_OF_PROCESS:
- g_value_set_boolean (value, applet->priv->out_of_process);
- break;
- case PROP_ID:
- g_value_set_string (value, applet->priv->id);
- break;
- case PROP_CLOSURE:
- g_value_set_pointer (value, applet->priv->closure);
- break;
- case PROP_CONNECTION:
- g_value_set_object (value, applet->priv->connection);
- break;
- case PROP_PREFS_PATH:
- g_value_set_string (value, applet->priv->prefs_path);
- break;
- case PROP_ORIENT:
- g_value_set_uint (value, applet->priv->orient);
- break;
- case PROP_SIZE:
- g_value_set_uint (value, applet->priv->size);
- break;
- case PROP_BACKGROUND:
- g_value_set_string (value, applet->priv->background);
- break;
- case PROP_FLAGS:
- g_value_set_uint (value, applet->priv->flags);
- break;
- case PROP_SIZE_HINTS: {
- GVariant **children;
- GVariant *variant;
- gint i;
+ applet = MATE_PANEL_APPLET (object);
+ priv = mate_panel_applet_get_instance_private (applet);
- children = g_new (GVariant *, applet->priv->size_hints_len);
- for (i = 0; i < applet->priv->size_hints_len; i++)
- children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
- variant = g_variant_new_array (G_VARIANT_TYPE_INT32,
- children, applet->priv->size_hints_len);
- g_free (children);
- g_value_set_pointer (value, variant);
- }
- break;
- case PROP_LOCKED:
- g_value_set_boolean (value, applet->priv->locked);
- break;
- case PROP_LOCKED_DOWN:
- g_value_set_boolean (value, applet->priv->locked_down);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ switch (prop_id) {
+ case PROP_OUT_OF_PROCESS:
+ g_value_set_boolean (value, priv->out_of_process);
+ break;
+ case PROP_ID:
+ g_value_set_string (value, priv->id);
+ break;
+ case PROP_CLOSURE:
+ g_value_set_pointer (value, priv->closure);
+ break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, priv->connection);
+ break;
+ case PROP_PREFS_PATH:
+ g_value_set_string (value, priv->prefs_path);
+ break;
+ case PROP_ORIENT:
+ g_value_set_uint (value, priv->orient);
+ break;
+ case PROP_SIZE:
+ g_value_set_uint (value, priv->size);
+ break;
+ case PROP_BACKGROUND:
+ g_value_set_string (value, priv->background);
+ break;
+ case PROP_FLAGS:
+ g_value_set_uint (value, priv->flags);
+ break;
+ case PROP_SIZE_HINTS: {
+ GVariant **children;
+ GVariant *variant;
+ gint i;
+
+ children = g_new (GVariant *, priv->size_hints_len);
+ for (i = 0; i < priv->size_hints_len; i++)
+ children[i] = g_variant_new_int32 (priv->size_hints[i]);
+ variant = g_variant_new_array (G_VARIANT_TYPE_INT32,
+ children, priv->size_hints_len);
+ g_free (children);
+ g_value_set_pointer (value, variant);
+ break;
+ }
+ case PROP_LOCKED:
+ g_value_set_boolean (value, priv->locked);
+ break;
+ case PROP_LOCKED_DOWN:
+ g_value_set_boolean (value, priv->locked_down);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -1632,22 +1729,26 @@ mate_panel_applet_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- MatePanelApplet *applet = MATE_PANEL_APPLET (object);
+ MatePanelApplet *applet;
+ MatePanelAppletPrivate *priv;
+
+ applet = MATE_PANEL_APPLET (object);
+ priv = mate_panel_applet_get_instance_private (applet);
switch (prop_id) {
case PROP_OUT_OF_PROCESS:
- applet->priv->out_of_process = g_value_get_boolean (value);
+ priv->out_of_process = g_value_get_boolean (value);
break;
case PROP_ID:
- applet->priv->id = g_value_dup_string (value);
+ priv->id = g_value_dup_string (value);
break;
case PROP_CLOSURE:
- applet->priv->closure = g_value_get_pointer (value);
- g_closure_set_marshal (applet->priv->closure,
+ priv->closure = g_value_get_pointer (value);
+ g_closure_set_marshal (priv->closure,
mate_panel_applet_marshal_BOOLEAN__STRING);
break;
case PROP_CONNECTION:
- applet->priv->connection = g_value_dup_object (value);
+ priv->connection = g_value_dup_object (value);
break;
case PROP_PREFS_PATH:
mate_panel_applet_set_preferences_path (applet, g_value_get_string (value));
@@ -1700,13 +1801,15 @@ add_tab_bindings (GtkBindingSet *binding_set,
static void
mate_panel_applet_setup (MatePanelApplet *applet)
{
+ MatePanelAppletPrivate *priv;
GValue value = {0, };
GArray *params;
gint i;
gboolean ret;
- g_assert (applet->priv->id != NULL &&
- applet->priv->closure != NULL);
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ g_assert ((priv->id != NULL) && (priv->closure != NULL));
params = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 2);
value.g_type = 0;
@@ -1716,16 +1819,16 @@ mate_panel_applet_setup (MatePanelApplet *applet)
value.g_type = 0;
g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, applet->priv->id);
+ g_value_set_string (&value, priv->id);
g_array_append_val (params, value);
value.g_type = 0;
g_value_init (&value, G_TYPE_BOOLEAN);
- g_closure_invoke (applet->priv->closure,
- &value, params->len,
- (GValue *) params->data,
- NULL);
+ g_closure_invoke (priv->closure,
+ &value, params->len,
+ (GValue *) params->data,
+ NULL);
for (i = 0; i < params->len; i++)
g_value_unset (&g_array_index (params, GValue, i));
@@ -1789,28 +1892,30 @@ static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
static void
mate_panel_applet_init (MatePanelApplet *applet)
{
- applet->priv = mate_panel_applet_get_instance_private (applet);
-
- applet->priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
- applet->priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
- applet->priv->size = 24;
-
- applet->priv->panel_action_group = gtk_action_group_new ("PanelActions");
- gtk_action_group_set_translation_domain (applet->priv->panel_action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (applet->priv->panel_action_group,
- menu_entries,
- G_N_ELEMENTS (menu_entries),
- applet);
- gtk_action_group_add_toggle_actions (applet->priv->panel_action_group,
- menu_toggle_entries,
- G_N_ELEMENTS (menu_toggle_entries),
- applet);
-
- applet->priv->ui_manager = gtk_ui_manager_new ();
- gtk_ui_manager_insert_action_group (applet->priv->ui_manager,
- applet->priv->panel_action_group, 1);
- gtk_ui_manager_add_ui_from_string (applet->priv->ui_manager,
- panel_menu_ui, -1, NULL);
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
+ priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
+ priv->size = 24;
+
+ priv->panel_action_group = gtk_action_group_new ("PanelActions");
+ gtk_action_group_set_translation_domain (priv->panel_action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (priv->panel_action_group,
+ menu_entries,
+ G_N_ELEMENTS (menu_entries),
+ applet);
+ gtk_action_group_add_toggle_actions (priv->panel_action_group,
+ menu_toggle_entries,
+ G_N_ELEMENTS (menu_toggle_entries),
+ applet);
+
+ priv->ui_manager = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (priv->ui_manager,
+ priv->panel_action_group, 1);
+ gtk_ui_manager_add_ui_from_string (priv->ui_manager,
+ panel_menu_ui, -1, NULL);
gtk_widget_set_events (GTK_WIDGET (applet),
GDK_BUTTON_PRESS_MASK |
@@ -1824,35 +1929,38 @@ mate_panel_applet_constructor (GType type,
{
GObject *object;
MatePanelApplet *applet;
+ MatePanelAppletPrivate *priv;
object = G_OBJECT_CLASS (mate_panel_applet_parent_class)->constructor (type,
n_construct_properties,
construct_properties);
applet = MATE_PANEL_APPLET (object);
+ priv = mate_panel_applet_get_instance_private (applet);
- if (!applet->priv->out_of_process)
+ if (!priv->out_of_process)
return object;
#ifdef HAVE_X11
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
{
- applet->priv->plug = gtk_plug_new (0);
-
- GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (applet->priv->plug));
- GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
- gtk_widget_set_visual (GTK_WIDGET (applet->priv->plug), visual);
GtkStyleContext *context;
- context = gtk_widget_get_style_context (GTK_WIDGET(applet->priv->plug));
- gtk_style_context_add_class (context,"gnome-panel-menu-bar");
- gtk_style_context_add_class (context,"mate-panel-menu-bar");
- gtk_widget_set_name (GTK_WIDGET (applet->priv->plug), "PanelPlug");
+ GtkWidget *widget;
+
+ priv->plug = gtk_plug_new (0);
+ widget = GTK_WIDGET (priv->plug);
+ gtk_widget_set_visual (widget,
+ gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_add_class (context, "gnome-panel-menu-bar");
+ gtk_style_context_add_class (context, "mate-panel-menu-bar");
+ gtk_widget_set_name (widget, "PanelPlug");
_mate_panel_applet_prepare_css (context);
- g_signal_connect_swapped (G_OBJECT (applet->priv->plug), "embedded",
- G_CALLBACK (mate_panel_applet_setup),
- applet);
+ g_signal_connect_swapped (G_OBJECT (priv->plug), "embedded",
+ G_CALLBACK (mate_panel_applet_setup),
+ applet);
- gtk_container_add (GTK_CONTAINER (applet->priv->plug), GTK_WIDGET (applet));
+ gtk_container_add (GTK_CONTAINER (priv->plug), GTK_WIDGET (applet));
} else
#endif
{ /* not using X11 */
@@ -2119,35 +2227,35 @@ get_property_cb (GDBusConnection *connection,
GError **error,
gpointer user_data)
{
- MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
- GVariant *retval = NULL;
+ MatePanelAppletPrivate *priv;
+ GVariant *retval = NULL;
+
+ priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (user_data));
if (g_strcmp0 (property_name, "PrefsPath") == 0) {
- retval = g_variant_new_string (applet->priv->prefs_path ?
- applet->priv->prefs_path : "");
+ retval = g_variant_new_string (priv->prefs_path ? priv->prefs_path : "");
} else if (g_strcmp0 (property_name, "Orient") == 0) {
- retval = g_variant_new_uint32 (applet->priv->orient);
+ retval = g_variant_new_uint32 (priv->orient);
} else if (g_strcmp0 (property_name, "Size") == 0) {
- retval = g_variant_new_uint32 (applet->priv->size);
+ retval = g_variant_new_uint32 (priv->size);
} else if (g_strcmp0 (property_name, "Background") == 0) {
- retval = g_variant_new_string (applet->priv->background ?
- applet->priv->background : "");
+ retval = g_variant_new_string (priv->background ? priv->background : "");
} else if (g_strcmp0 (property_name, "Flags") == 0) {
- retval = g_variant_new_uint32 (applet->priv->flags);
+ retval = g_variant_new_uint32 (priv->flags);
} else if (g_strcmp0 (property_name, "SizeHints") == 0) {
GVariant **children;
gint i;
- children = g_new (GVariant *, applet->priv->size_hints_len);
- for (i = 0; i < applet->priv->size_hints_len; i++)
- children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
+ children = g_new (GVariant *, priv->size_hints_len);
+ for (i = 0; i < priv->size_hints_len; i++)
+ children[i] = g_variant_new_int32 (priv->size_hints[i]);
retval = g_variant_new_array (G_VARIANT_TYPE_INT32,
- children, applet->priv->size_hints_len);
+ children, priv->size_hints_len);
g_free (children);
} else if (g_strcmp0 (property_name, "Locked") == 0) {
- retval = g_variant_new_boolean (applet->priv->locked);
+ retval = g_variant_new_boolean (priv->locked);
} else if (g_strcmp0 (property_name, "LockedDown") == 0) {
- retval = g_variant_new_boolean (applet->priv->locked_down);
+ retval = g_variant_new_boolean (priv->locked_down);
}
return retval;
@@ -2223,22 +2331,24 @@ static GDBusNodeInfo *introspection_data = NULL;
static void
mate_panel_applet_register_object (MatePanelApplet *applet)
{
+ MatePanelAppletPrivate *priv;
GError *error = NULL;
static gint id = 0;
if (!introspection_data)
introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
- applet->priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH, applet->priv->id, id++);
- applet->priv->object_id =
- g_dbus_connection_register_object (applet->priv->connection,
- applet->priv->object_path,
- introspection_data->interfaces[0],
- &interface_vtable,
- applet, NULL,
- &error);
- if (!applet->priv->object_id) {
- g_printerr ("Failed to register object %s: %s\n", applet->priv->object_path, error->message);
+ priv = mate_panel_applet_get_instance_private (applet);
+ priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH, priv->id, id++);
+ priv->object_id =
+ g_dbus_connection_register_object (priv->connection,
+ priv->object_path,
+ introspection_data->interfaces[0],
+ &interface_vtable,
+ applet, NULL,
+ &error);
+ if (!priv->object_id) {
+ g_printerr ("Failed to register object %s: %s\n", priv->object_path, error->message);
g_error_free (error);
}
}
@@ -2311,7 +2421,6 @@ _mate_panel_applet_factory_main_internal (const gchar *factory_id,
GType applet_type,
MatePanelAppletFactoryCallback callback,
gpointer user_data)
-
{
MatePanelAppletFactory* factory;
GClosure* closure;
@@ -2418,15 +2527,19 @@ guint32
mate_panel_applet_get_xid (MatePanelApplet *applet,
GdkScreen *screen)
{
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
/* out_of_process should only be true on X11, so an extra runtime Wayland check is not needed */
- if (applet->priv->out_of_process == FALSE)
+ if (priv->out_of_process == FALSE)
return 0;
#ifdef HAVE_X11
- gtk_window_set_screen (GTK_WINDOW (applet->priv->plug), screen);
- gtk_widget_show (applet->priv->plug);
+ gtk_window_set_screen (GTK_WINDOW (priv->plug), screen);
+ gtk_widget_show (priv->plug);
- return gtk_plug_get_id (GTK_PLUG (applet->priv->plug));
+ return gtk_plug_get_id (GTK_PLUG (priv->plug));
#else
return 0;
#endif
@@ -2435,7 +2548,11 @@ mate_panel_applet_get_xid (MatePanelApplet *applet,
const gchar *
mate_panel_applet_get_object_path (MatePanelApplet *applet)
{
- return applet->priv->object_path;
+ MatePanelAppletPrivate *priv;
+
+ priv = mate_panel_applet_get_instance_private (applet);
+
+ return priv->object_path;
}
G_MODULE_EXPORT GtkWidget *