Browse Source

Add gtk builder code of the plugins in a common file.

upstream/xfce4-panel-4.10.1
Nick Schermer 13 years ago
parent
commit
fbef637421
  1. 8
      common/Makefile.am
  2. 80
      common/panel-builder.c
  3. 31
      common/panel-builder.h
  4. 72
      plugins/actions/actions.c
  5. 168
      plugins/launcher/launcher-dialog.c
  6. 71
      plugins/pager/pager.c
  7. 39
      plugins/separator/separator.c
  8. 60
      plugins/systray/systray.c
  9. 67
      plugins/tasklist/tasklist.c
  10. 43
      plugins/windowmenu/windowmenu.c

8
common/Makefile.am

@ -10,18 +10,22 @@ noinst_LTLIBRARIES = \
libpanel-xfconf.la
libpanel_xfconf_la_SOURCES = \
panel-builder.c \
panel-builder.h \
panel-xfconf.c \
panel-xfconf.h
libpanel_xfconf_la_CFLAGS = \
$(XFCONF_CFLAGS)
$(XFCONF_CFLAGS) \
$(GTK_CFLAGS)
libpanel_xfconf_la_LDFLAGS = \
-no-undefined \
$(PLATFORM_LDFLAGS)
libpanel_xfconf_la_LIBADD = \
$(XFCONF_LIBS)
$(XFCONF_LIBS) \
$(GTK_LIBS)
EXTRA_DIST = \
panel-dbus.h \

80
common/panel-builder.c

@ -0,0 +1,80 @@
/* $Id$ */
/*
* Copyright (C) 2009 Nick Schermer <nick@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <common/panel-builder.h>
GtkBuilder *
panel_builder_new (XfcePanelPlugin *panel_plugin,
const gchar *buffer,
gsize length,
GObject **dialog_return)
{
GError *error = NULL;
GtkBuilder *builder;
GObject *dialog, *button;
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (panel_plugin), NULL);
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, buffer, length, &error))
{
dialog = gtk_builder_get_object (builder, "dialog");
if (G_LIKELY (dialog != NULL))
{
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) g_object_unref, builder);
xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) xfce_panel_plugin_unblock_menu,
panel_plugin);
button = gtk_builder_get_object (builder, "close-button");
if (G_LIKELY (button != NULL))
g_signal_connect_swapped (G_OBJECT (button), "clicked",
G_CALLBACK (gtk_widget_destroy), dialog);
if (G_LIKELY (dialog_return != NULL))
*dialog_return = dialog;
return builder;
}
else
{
g_set_error_literal (&error, 0, 0, "No widget with the name \"dialog\" found");
}
}
g_critical ("Faild to construct the builder for plugin %s-%d: %s.",
xfce_panel_plugin_get_name (panel_plugin),
xfce_panel_plugin_get_unique_id (panel_plugin),
error->message);
g_error_free (error);
g_object_unref (G_OBJECT (builder));
return NULL;
}

31
common/panel-builder.h

@ -0,0 +1,31 @@
/* $Id$ */
/*
* Copyright (C) 2009 Nick Schermer <nick@xfce.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __PANEL_BUILDER_H__
#define __PANEL_BUILDER_H__
#include <gtk/gtk.h>
#include <libxfce4panel/libxfce4panel.h>
GtkBuilder *panel_builder_new (XfcePanelPlugin *panel_plugin,
const gchar *buffer,
gsize length,
GObject **dialog_return) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
#endif /* !__PANEL_BUILDER_H__ */

72
plugins/actions/actions.c

@ -26,6 +26,7 @@
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-xfconf.h>
#include <common/panel-builder.h>
#include <exo/exo.h>
#include "actions.h"
@ -355,50 +356,33 @@ actions_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
panel_return_if_fail (XFCE_IS_ACTIONS_PLUGIN (plugin));
/* load the dialog from the ui file */
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, actions_dialog_ui,
actions_dialog_ui_length, NULL))
{
dialog = gtk_builder_get_object (builder, "dialog");
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify)
xfce_panel_plugin_unblock_menu, panel_plugin);
object = gtk_builder_get_object (builder, "close-button");
g_signal_connect_swapped (G_OBJECT (object), "clicked",
G_CALLBACK (gtk_widget_destroy), dialog);
/* populate the first store */
object = gtk_builder_get_object (builder, "first-action-model");
for (i = 1; i < G_N_ELEMENTS (action_entries); i++)
gtk_list_store_insert_with_values (GTK_LIST_STORE (object), NULL, i - 1,
0, _(action_entries[i].title), -1);
object = gtk_builder_get_object (builder, "first-action");
exo_mutual_binding_new (G_OBJECT (plugin), "first-action",
G_OBJECT (object), "active");
/* populate the second store */
object = gtk_builder_get_object (builder, "second-action-model");
for (i = 0; i < G_N_ELEMENTS (action_entries); i++)
gtk_list_store_insert_with_values (GTK_LIST_STORE (object), NULL, i,
0, _(action_entries[i].title), -1);
object = gtk_builder_get_object (builder, "second-action");
exo_mutual_binding_new (G_OBJECT (plugin), "second-action",
G_OBJECT (object), "active");
gtk_widget_show (GTK_WIDGET (dialog));
}
else
{
/* release the builder */
g_object_unref (G_OBJECT (builder));
}
/* setup the dialog */
builder = panel_builder_new (panel_plugin, actions_dialog_ui,
actions_dialog_ui_length, &dialog);
if (G_UNLIKELY (builder == NULL))
return;
/* populate the first store */
object = gtk_builder_get_object (builder, "first-action-model");
for (i = 1; i < G_N_ELEMENTS (action_entries); i++)
gtk_list_store_insert_with_values (GTK_LIST_STORE (object), NULL, i - 1,
0, _(action_entries[i].title), -1);
object = gtk_builder_get_object (builder, "first-action");
exo_mutual_binding_new (G_OBJECT (plugin), "first-action",
G_OBJECT (object), "active");
/* populate the second store */
object = gtk_builder_get_object (builder, "second-action-model");
for (i = 0; i < G_N_ELEMENTS (action_entries); i++)
gtk_list_store_insert_with_values (GTK_LIST_STORE (object), NULL, i,
0, _(action_entries[i].title), -1);
object = gtk_builder_get_object (builder, "second-action");
exo_mutual_binding_new (G_OBJECT (plugin), "second-action",
G_OBJECT (object), "active");
gtk_widget_show (GTK_WIDGET (dialog));
}

168
plugins/launcher/launcher-dialog.c

@ -32,6 +32,7 @@
#include <xfconf/xfconf.h>
#include <common/panel-private.h>
#include <common/panel-builder.h>
#include "launcher.h"
#include "launcher-dialog.h"
@ -574,12 +575,8 @@ launcher_dialog_response (GtkWidget *widget,
/* disconnect from the menu items */
launcher_dialog_items_unload (dialog);
/* destroy the dialog and release the builder */
/* destroy the dialog */
gtk_widget_destroy (widget);
g_object_unref (G_OBJECT (dialog->builder));
/* unblock plugin menu */
xfce_panel_plugin_unblock_menu (XFCE_PANEL_PLUGIN (dialog->plugin));
/* cleanup */
g_slice_free (LauncherPluginDialog, dialog);
@ -745,96 +742,85 @@ launcher_dialog_show (LauncherPlugin *plugin)
panel_return_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin));
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, launcher_dialog_ui,
launcher_dialog_ui_length, NULL))
{
/* create structure */
dialog = g_slice_new0 (LauncherPluginDialog);
dialog->builder = builder;
dialog->plugin = plugin;
dialog->items = NULL;
/* block plugin menu */
xfce_panel_plugin_block_menu (XFCE_PANEL_PLUGIN (plugin));
/* get dialog from builder, release builder when dialog is destroyed */
window = gtk_builder_get_object (builder, "dialog");
xfce_panel_plugin_take_window (XFCE_PANEL_PLUGIN (plugin), GTK_WINDOW (window));
g_signal_connect (G_OBJECT (window), "response",
G_CALLBACK (launcher_dialog_response), dialog);
/* connect item buttons */
for (i = 0; i < G_N_ELEMENTS (button_names); i++)
{
object = gtk_builder_get_object (builder, button_names[i]);
panel_return_if_fail (GTK_IS_WIDGET (object));
g_signal_connect (G_OBJECT (object), "clicked",
G_CALLBACK (launcher_dialog_item_button_clicked), dialog);
}
/* setup treeview selection */
object = gtk_builder_get_object (builder, "item-treeview");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (launcher_dialog_tree_selection_changed), dialog);
launcher_dialog_tree_selection_changed (selection, dialog);
/* setup the dialog */
builder = panel_builder_new (XFCE_PANEL_PLUGIN (plugin), launcher_dialog_ui,
launcher_dialog_ui_length, &window);
if (G_UNLIKELY (builder == NULL))
return;
/* connect bindings to the advanced properties */
for (i = 0; i < G_N_ELEMENTS (binding_names); i++)
{
object = gtk_builder_get_object (builder, binding_names[i]);
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), binding_names[i],
G_OBJECT (object), "active");
}
/* create structure */
dialog = g_slice_new0 (LauncherPluginDialog);
dialog->builder = builder;
dialog->plugin = plugin;
dialog->items = NULL;
/* setup responses for the add dialog */
object = gtk_builder_get_object (builder, "dialog-add");
g_signal_connect (G_OBJECT (object), "response",
G_CALLBACK (launcher_dialog_add_response), dialog);
g_signal_connect (G_OBJECT (object), "delete-event",
G_CALLBACK (gtk_true), NULL);
/* setup sorting in the add dialog */
object = gtk_builder_get_object (builder, "add-store");
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (object),
COL_NAME, GTK_SORT_ASCENDING);
/* allow selecting multiple items in the add dialog */
object = gtk_builder_get_object (builder, "add-treeview");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (launcher_dialog_add_selection_changed), dialog);
/* setup search filter in the add dialog */
object = gtk_builder_get_object (builder, "add-store-filter");
item = gtk_builder_get_object (builder, "add-search");
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (object),
launcher_dialog_add_visible_function, item, NULL);
g_signal_connect_swapped (G_OBJECT (item), "changed",
G_CALLBACK (gtk_tree_model_filter_refilter), object);
/* setup the icon size in the icon renderers */
object = gtk_builder_get_object (builder, "addrenderericon");
g_object_set (G_OBJECT (object), "stock-size", GTK_ICON_SIZE_DND, NULL);
object = gtk_builder_get_object (builder, "itemrenderericon");
g_object_set (G_OBJECT (object), "stock-size", GTK_ICON_SIZE_DND, NULL);
/* load the plugin items */
launcher_dialog_items_load (dialog);
g_signal_connect_swapped (G_OBJECT (plugin), "items-changed",
G_CALLBACK (launcher_dialog_items_load), dialog);
g_signal_connect (G_OBJECT (window), "response",
G_CALLBACK (launcher_dialog_response), dialog);
/* show the dialog */
gtk_widget_show (GTK_WIDGET (window));
/* connect item buttons */
for (i = 0; i < G_N_ELEMENTS (button_names); i++)
{
object = gtk_builder_get_object (builder, button_names[i]);
panel_return_if_fail (GTK_IS_WIDGET (object));
g_signal_connect (G_OBJECT (object), "clicked",
G_CALLBACK (launcher_dialog_item_button_clicked), dialog);
}
else
/* setup treeview selection */
object = gtk_builder_get_object (builder, "item-treeview");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (launcher_dialog_tree_selection_changed), dialog);
launcher_dialog_tree_selection_changed (selection, dialog);
/* connect bindings to the advanced properties */
for (i = 0; i < G_N_ELEMENTS (binding_names); i++)
{
/* release the builder and fire error */
g_object_unref (G_OBJECT (builder));
panel_assert_not_reached ();
object = gtk_builder_get_object (builder, binding_names[i]);
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), binding_names[i],
G_OBJECT (object), "active");
}
/* setup responses for the add dialog */
object = gtk_builder_get_object (builder, "dialog-add");
g_signal_connect (G_OBJECT (object), "response",
G_CALLBACK (launcher_dialog_add_response), dialog);
g_signal_connect (G_OBJECT (object), "delete-event",
G_CALLBACK (gtk_true), NULL);
/* setup sorting in the add dialog */
object = gtk_builder_get_object (builder, "add-store");
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (object),
COL_NAME, GTK_SORT_ASCENDING);
/* allow selecting multiple items in the add dialog */
object = gtk_builder_get_object (builder, "add-treeview");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (object));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (launcher_dialog_add_selection_changed), dialog);
/* setup search filter in the add dialog */
object = gtk_builder_get_object (builder, "add-store-filter");
item = gtk_builder_get_object (builder, "add-search");
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (object),
launcher_dialog_add_visible_function, item, NULL);
g_signal_connect_swapped (G_OBJECT (item), "changed",
G_CALLBACK (gtk_tree_model_filter_refilter), object);
/* setup the icon size in the icon renderers */
object = gtk_builder_get_object (builder, "addrenderericon");
g_object_set (G_OBJECT (object), "stock-size", GTK_ICON_SIZE_DND, NULL);
object = gtk_builder_get_object (builder, "itemrenderericon");
g_object_set (G_OBJECT (object), "stock-size", GTK_ICON_SIZE_DND, NULL);
/* load the plugin items */
launcher_dialog_items_load (dialog);
g_signal_connect_swapped (G_OBJECT (plugin), "items-changed",
G_CALLBACK (launcher_dialog_items_load), dialog);
/* show the dialog */
gtk_widget_show (GTK_WIDGET (window));
}

71
plugins/pager/pager.c

@ -27,6 +27,7 @@
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-xfconf.h>
#include <common/panel-builder.h>
#include <libwnck/libwnck.h>
#include <exo/exo.h>
@ -411,9 +412,6 @@ pager_plugin_configure_destroyed (gpointer data,
g_signal_handlers_disconnect_by_func (G_OBJECT (plugin->wnck_screen),
pager_plugin_configure_n_workspaces_changed,
where_the_object_was);
/* unblock the menu */
xfce_panel_plugin_unblock_menu (XFCE_PANEL_PLUGIN (plugin));
}
@ -427,52 +425,37 @@ pager_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
panel_return_if_fail (XFCE_IS_PAGER_PLUGIN (plugin));
/* load the dialog from the ui file */
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, pager_dialog_ui,
pager_dialog_ui_length, NULL))
{
/* signals to monitor number of workspace changes */
g_signal_connect (G_OBJECT (plugin->wnck_screen), "workspace-created",
G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
g_signal_connect (G_OBJECT (plugin->wnck_screen), "workspace-destroyed",
G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (builder), pager_plugin_configure_destroyed, plugin);
/* setup the dialog */
builder = panel_builder_new (panel_plugin, pager_dialog_ui,
pager_dialog_ui_length, &dialog);
if (G_UNLIKELY (builder == NULL))
return;
dialog = gtk_builder_get_object (builder, "dialog");
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
/* signals to monitor number of workspace changes */
g_signal_connect (G_OBJECT (plugin->wnck_screen), "workspace-created",
G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
g_signal_connect (G_OBJECT (plugin->wnck_screen), "workspace-destroyed",
G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
g_object_weak_ref (G_OBJECT (builder), pager_plugin_configure_destroyed, plugin);
object = gtk_builder_get_object (builder, "close-button");
g_signal_connect_swapped (G_OBJECT (object), "clicked",
G_CALLBACK (gtk_widget_destroy), dialog);
object = gtk_builder_get_object (builder, "settings-button");
g_signal_connect (G_OBJECT (object), "clicked",
G_CALLBACK (pager_plugin_configure_workspace_settings), dialog);
object = gtk_builder_get_object (builder, "settings-button");
g_signal_connect (G_OBJECT (object), "clicked",
G_CALLBACK (pager_plugin_configure_workspace_settings), dialog);
object = gtk_builder_get_object (builder, "workspace-scrolling");
exo_mutual_binding_new (G_OBJECT (plugin), "workspace-scrolling",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "workspace-scrolling");
exo_mutual_binding_new (G_OBJECT (plugin), "workspace-scrolling",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "show-names");
exo_mutual_binding_new (G_OBJECT (plugin), "show-names",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "show-names");
exo_mutual_binding_new (G_OBJECT (plugin), "show-names",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "rows");
exo_mutual_binding_new (G_OBJECT (plugin), "rows",
G_OBJECT (object), "value");
object = gtk_builder_get_object (builder, "rows");
exo_mutual_binding_new (G_OBJECT (plugin), "rows",
G_OBJECT (object), "value");
/* update the rows limit */
pager_plugin_configure_n_workspaces_changed (plugin->wnck_screen, NULL, builder);
/* update the rows limit */
pager_plugin_configure_n_workspaces_changed (plugin->wnck_screen, NULL, builder);
gtk_widget_show (GTK_WIDGET (dialog));
}
else
{
/* release the builder */
g_object_unref (G_OBJECT (builder));
}
gtk_widget_show (GTK_WIDGET (dialog));
}

39
plugins/separator/separator.c

@ -26,6 +26,7 @@
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4util/libxfce4util.h>
#include <common/panel-xfconf.h>
#include <common/panel-builder.h>
#include <exo/exo.h>
#include "separator.h"
@ -313,35 +314,21 @@ separator_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
panel_return_if_fail (XFCE_IS_SEPARATOR_PLUGIN (plugin));
/* load the dialog from the ui file */
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, separator_dialog_ui, separator_dialog_ui_length, NULL))
{
dialog = gtk_builder_get_object (builder, "dialog");
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) xfce_panel_plugin_unblock_menu, panel_plugin);
/* setup the dialog */
builder = panel_builder_new (panel_plugin, separator_dialog_ui,
separator_dialog_ui_length, &dialog);
if (G_UNLIKELY (builder == NULL))
return;
object = gtk_builder_get_object (builder, "close-button");
g_signal_connect_swapped (G_OBJECT (object), "clicked", G_CALLBACK (gtk_widget_destroy), dialog);
object = gtk_builder_get_object (builder, "style");
exo_mutual_binding_new (G_OBJECT (plugin), "style",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "style");
exo_mutual_binding_new (G_OBJECT (plugin), "style",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "expand");
exo_mutual_binding_new (G_OBJECT (plugin), "expand",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "expand");
exo_mutual_binding_new (G_OBJECT (plugin), "expand",
G_OBJECT (object), "active");
gtk_widget_show (GTK_WIDGET (dialog));
}
else
{
/* release the builder */
g_object_unref (G_OBJECT (builder));
}
gtk_widget_show (GTK_WIDGET (dialog));
}

60
plugins/systray/systray.c

@ -26,6 +26,7 @@
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-private.h>
#include <common/panel-xfconf.h>
#include <common/panel-builder.h>
#include <exo/exo.h>
#include "systray.h"
@ -451,44 +452,27 @@ systray_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
if (xfce_titled_dialog_get_type () == 0)
return;
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, systray_dialog_ui,
systray_dialog_ui_length, NULL))
{
dialog = gtk_builder_get_object (builder, "dialog");
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify)
xfce_panel_plugin_unblock_menu, panel_plugin);
object = gtk_builder_get_object (builder, "close-button");
panel_return_if_fail (GTK_IS_WIDGET (object));
g_signal_connect_swapped (G_OBJECT (object), "clicked",
G_CALLBACK (gtk_widget_destroy), dialog);
object = gtk_builder_get_object (builder, "rows");
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), "rows",
G_OBJECT (object), "value");
object = gtk_builder_get_object (builder, "show-frame");
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), "show-frame",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "applications-store");
panel_return_if_fail (GTK_IS_LIST_STORE (object));
systray_plugin_dialog_add_application_names (plugin, GTK_LIST_STORE (object));
gtk_widget_show (GTK_WIDGET (dialog));
}
else
{
/* release the builder */
g_object_unref (G_OBJECT (builder));
}
/* setup the dialog */
builder = panel_builder_new (panel_plugin, systray_dialog_ui,
systray_dialog_ui_length, &dialog);
if (G_UNLIKELY (builder == NULL))
return;
object = gtk_builder_get_object (builder, "rows");
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), "rows",
G_OBJECT (object), "value");
object = gtk_builder_get_object (builder, "show-frame");
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), "show-frame",
G_OBJECT (object), "active");
object = gtk_builder_get_object (builder, "applications-store");
panel_return_if_fail (GTK_IS_LIST_STORE (object));
systray_plugin_dialog_add_application_names (plugin, GTK_LIST_STORE (object));
gtk_widget_show (GTK_WIDGET (dialog));
}

67
plugins/tasklist/tasklist.c

@ -24,6 +24,7 @@
#include <exo/exo.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-xfconf.h>
#include <common/panel-builder.h>
#include <libxfce4panel/libxfce4panel.h>
#include "tasklist-widget.h"
@ -180,51 +181,35 @@ tasklist_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
GObject *dialog;
GObject *object;
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, tasklist_dialog_ui,
tasklist_dialog_ui_length, NULL))
{
dialog = gtk_builder_get_object (builder, "dialog");
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify)
xfce_panel_plugin_unblock_menu, panel_plugin);
object = gtk_builder_get_object (builder, "close-button");
g_signal_connect_swapped (G_OBJECT (object), "clicked",
G_CALLBACK (gtk_widget_destroy), dialog);
/* setup the dialog */
builder = panel_builder_new (panel_plugin, tasklist_dialog_ui,
tasklist_dialog_ui_length, &dialog);
if (G_UNLIKELY (builder == NULL))
return;
#define TASKLIST_DIALOG_BIND(name, property) \
object = gtk_builder_get_object (builder, (name)); \
panel_return_if_fail (G_IS_OBJECT (object)); \
exo_mutual_binding_new (G_OBJECT (plugin->tasklist), (name), \
G_OBJECT (object), (property));
object = gtk_builder_get_object (builder, (name)); \
panel_return_if_fail (G_IS_OBJECT (object)); \
exo_mutual_binding_new (G_OBJECT (plugin->tasklist), (name), \
G_OBJECT (object), (property));
#define TASKLIST_DIALOG_BIND_INV(name, property) \
object = gtk_builder_get_object (builder, (name)); \
panel_return_if_fail (G_IS_OBJECT (object)); \
exo_mutual_binding_new_with_negation (G_OBJECT (plugin->tasklist), \
name, G_OBJECT (object), \
property);
TASKLIST_DIALOG_BIND ("show-labels", "active")
TASKLIST_DIALOG_BIND ("grouping", "active")
TASKLIST_DIALOG_BIND ("include-all-workspaces", "active")
TASKLIST_DIALOG_BIND ("flat-buttons", "active")
TASKLIST_DIALOG_BIND_INV ("switch-workspace-on-unminimize", "active")
TASKLIST_DIALOG_BIND ("show-only-minimized", "active")
TASKLIST_DIALOG_BIND ("show-wireframes", "active")
TASKLIST_DIALOG_BIND ("show-handle", "active")
gtk_widget_show (GTK_WIDGET (dialog));
}
else
{
/* release the builder */
g_object_unref (G_OBJECT (builder));
}
object = gtk_builder_get_object (builder, (name)); \
panel_return_if_fail (G_IS_OBJECT (object)); \
exo_mutual_binding_new_with_negation (G_OBJECT (plugin->tasklist), \
name, G_OBJECT (object), \
property);
TASKLIST_DIALOG_BIND ("show-labels", "active")
TASKLIST_DIALOG_BIND ("grouping", "active")
TASKLIST_DIALOG_BIND ("include-all-workspaces", "active")
TASKLIST_DIALOG_BIND ("flat-buttons", "active")
TASKLIST_DIALOG_BIND_INV ("switch-workspace-on-unminimize", "active")
TASKLIST_DIALOG_BIND ("show-only-minimized", "active")
TASKLIST_DIALOG_BIND ("show-wireframes", "active")
TASKLIST_DIALOG_BIND ("show-handle", "active")
gtk_widget_show (GTK_WIDGET (dialog));
}

43
plugins/windowmenu/windowmenu.c

@ -26,6 +26,7 @@
#include <libxfce4panel/libxfce4panel.h>
#include <libwnck/libwnck.h>
#include <common/panel-xfconf.h>
#include <common/panel-builder.h>
#include <gdk/gdkkeysyms.h>
#include <common/panel-private.h>
@ -493,38 +494,22 @@ window_menu_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
"urgentcy-notification", "all-workspaces",
"style" };
builder = gtk_builder_new ();
if (gtk_builder_add_from_string (builder, windowmenu_dialog_ui,
windowmenu_dialog_ui_length, NULL))
{
dialog = gtk_builder_get_object (builder, "dialog");
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
xfce_panel_plugin_take_window (panel_plugin, GTK_WINDOW (dialog));
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify)
xfce_panel_plugin_unblock_menu, panel_plugin);
object = gtk_builder_get_object (builder, "close-button");
g_signal_connect_swapped (G_OBJECT (object), "clicked",
G_CALLBACK (gtk_widget_destroy), dialog);
/* connect bindings */
for (i = 0; i < G_N_ELEMENTS (names); i++)
{
object = gtk_builder_get_object (builder, names[i]);
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), names[i],
G_OBJECT (object), "active");
}
/* setup the dialog */
builder = panel_builder_new (panel_plugin, windowmenu_dialog_ui,
windowmenu_dialog_ui_length, &dialog);
if (G_UNLIKELY (builder == NULL))
return;
gtk_widget_show (GTK_WIDGET (dialog));
}
else
/* connect bindings */
for (i = 0; i < G_N_ELEMENTS (names); i++)
{
/* release the builder */
g_object_unref (G_OBJECT (builder));
object = gtk_builder_get_object (builder, names[i]);
panel_return_if_fail (GTK_IS_WIDGET (object));
exo_mutual_binding_new (G_OBJECT (plugin), names[i],
G_OBJECT (object), "active");
}
gtk_widget_show (GTK_WIDGET (dialog));
}

Loading…
Cancel
Save