[Xfce4-commits] <xfce4-panel:devel> Import the action buttons plugin.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:30:32 CEST 2009
Updating branch refs/heads/devel
to c6f9c730d822705dc3f2f8de93ec0dab9151d205 (commit)
from d2817c2065421f93d81b76b892fc5d18e81c3474 (commit)
commit c6f9c730d822705dc3f2f8de93ec0dab9151d205
Author: Nick Schermer <nick at xfce.org>
Date: Sun Mar 15 20:56:38 2009 +0100
Import the action buttons plugin.
configure.in.in | 1 +
plugins/Makefile.am | 1 +
plugins/{separator => actions}/Makefile.am | 40 +-
plugins/actions/actions-dialog.glade | 153 +++++++
plugins/actions/actions.c | 478 ++++++++++++++++++++
.../actions.desktop.in.in} | 8 +-
plugins/actions/actions.h | 44 ++
7 files changed, 700 insertions(+), 25 deletions(-)
diff --git a/configure.in.in b/configure.in.in
index a4aac2a..7bb0dfd 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -231,6 +231,7 @@ libxfce4panel/libxfce4panel-1.0.pc
panel/Makefile
wrapper/Makefile
plugins/Makefile
+plugins/actions/Makefile
plugins/clock/Makefile
plugins/launcher/Makefile
plugins/pager/Makefile
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2305198..7167902 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,6 +1,7 @@
# $Id$
SUBDIRS = \
+ actions \
clock \
launcher \
pager \
diff --git a/plugins/separator/Makefile.am b/plugins/actions/Makefile.am
similarity index 60%
copy from plugins/separator/Makefile.am
copy to plugins/actions/Makefile.am
index 1674d62..66806ba 100644
--- a/plugins/separator/Makefile.am
+++ b/plugins/actions/Makefile.am
@@ -2,7 +2,7 @@
INCLUDES = \
-I$(top_srcdir) \
- -DG_LOG_DOMAIN=\"libseparator\" \
+ -DG_LOG_DOMAIN=\"libactions\" \
-DLOCALEDIR=\"$(localedir)\" \
$(PLATFORM_CPPFLAGS)
@@ -10,67 +10,65 @@ plugindir = \
$(libdir)/xfce4/panel-plugins
plugin_LTLIBRARIES = \
- libseparator.la
+ libactions.la
-libseparator_built_sources = \
- separator-dialog_glade.h
+libactions_built_sources = \
+ actions-dialog_glade.h
-libseparator_la_SOURCES = \
- $(libseparator_built_sources) \
- separator.c \
- separator.h
+libactions_la_SOURCES = \
+ $(libactions_built_sources) \
+ actions.c \
+ actions.h
-libseparator_la_CFLAGS = \
+libactions_la_CFLAGS = \
$(GTK_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
- $(CAIRO_CFLAGS) \
$(LIBXFCE4UI_CFLAGS) \
$(PLATFORM_CFLAGS) \
$(EXO_CFLAGS) \
$(XFCONF_CFLAGS)
-libseparator_la_LDFLAGS = \
+libactions_la_LDFLAGS = \
-avoid-version \
-module \
-no-undefined \
$(PLATFORM_LDFLAGS)
-libseparator_la_LIBADD = \
+libactions_la_LIBADD = \
$(top_builddir)/libxfce4panel/libxfce4panel.la \
$(GTK_LIBS) \
- $(CAIRO_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
$(LIBXFCE4UI_LIBS) \
$(EXO_LIBS) \
$(XFCONF_LIBS)
-libseparator_la_DEPENDENCIES = \
+libactions_la_DEPENDENCIES = \
$(top_builddir)/libxfce4panel/libxfce4panel.la
if MAINTAINER_MODE
BUILT_SOURCES = \
- $(libseparator_built_sources)
+ $(libactions_built_sources)
DISTCLEANFILES = \
- $(libseparator_built_sources)
+ $(libactions_built_sources)
-separator-dialog_glade.h: separator-dialog.glade
- exo-csource --static --strip-comments --strip-content --name=separator_dialog_glade $< >$@
+actions-dialog_glade.h: actions-dialog.glade
+ exo-csource --static --strip-comments --strip-content --name=actions_dialog_glade $< >$@
endif
#
# .desktop file
#
desktopdir = $(datadir)/xfce4/panel-plugins
-desktop_in_in_files = separator.desktop.in.in
+desktop_in_in_files = actions.desktop.in.in
desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
-separator.desktop.in: $(desktop_in_in_files)
+actions.desktop.in: $(desktop_in_in_files)
sed -e "s,\@libdir\@,$(libdir),g" < $< > $@
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
EXTRA_DIST = \
- separator-dialog.glade \
+ actions-dialog.glade \
$(desktop_in_in_files)
DISTCLEANFILES = \
diff --git a/plugins/actions/actions-dialog.glade b/plugins/actions/actions-dialog.glade
new file mode 100644
index 0000000..e7d4679
--- /dev/null
+++ b/plugins/actions/actions-dialog.glade
@@ -0,0 +1,153 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-requires libxfce4ui 4.5 -->
+ <!-- interface-naming-policy project-wide -->
+ <object class="XfceTitledDialog" id="dialog">
+ <property name="title" translatable="yes">Action Button Properties</property>
+ <property name="icon_name">gtk-properties</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkFrame" id="frame5">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table5">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_First button:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">first-action</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Second button:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">second-action</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="first-action">
+ <property name="visible">True</property>
+ <property name="model">first-action-model</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="second-action">
+ <property name="visible">True</property>
+ <property name="model">second-action-model</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Button Actions</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="close-button">
+ <property name="label" translatable="yes">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">close-button</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkListStore" id="first-action-model">
+ <columns>
+ <!-- column-name title -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="second-action-model">
+ <columns>
+ <!-- column-name title -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+</interface>
diff --git a/plugins/actions/actions.c b/plugins/actions/actions.c
new file mode 100644
index 0000000..0e414e2
--- /dev/null
+++ b/plugins/actions/actions.c
@@ -0,0 +1,478 @@
+/* $Id$ */
+/*
+ * Copyright (c) 2005-2007 Jasper Huijsmans <jasper at xfce.org>
+ * Copyright (c) 2007-2009 Nick Schermer <nick at 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., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <libxfce4panel/libxfce4panel.h>
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4ui/libxfce4ui.h>
+#include <xfconf/xfconf.h>
+#include <exo/exo.h>
+
+#include "actions.h"
+#include "actions-dialog_glade.h"
+
+
+
+static void actions_plugin_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void actions_plugin_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void actions_plugin_construct (XfcePanelPlugin *panel_plugin);
+static void actions_plugin_free_data (XfcePanelPlugin *panel_plugin);
+static gboolean actions_plugin_size_changed (XfcePanelPlugin *panel_plugin,
+ gint size);
+static void actions_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
+static void actions_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
+ GtkOrientation orientation);
+static void actions_plugin_button_clicked (GtkWidget *button,
+ ActionsPlugin *plugin);
+
+
+
+typedef enum
+{
+ ACTION_DISABLED = 0,
+ ACTION_LOG_OUT_DIALOG,
+ ACTION_LOG_OUT,
+ ACTION_LOCK_SCREEN,
+ ACTION_SHUT_DOWN,
+ ACTION_RESTART,
+ ACTION_SUSPEND,
+ ACTION_HIBERNATE
+}
+ActionType;
+
+typedef struct
+{
+ ActionType type;
+ const gchar *title;
+ const gchar *icon_name;
+ const gchar *command;
+}
+ActionEntry;
+
+struct _ActionsPluginClass
+{
+ /* parent class */
+ XfcePanelPluginClass __parent__;
+
+};
+
+struct _ActionsPlugin
+{
+ /* parent type */
+ XfcePanelPlugin __parent__;
+
+ /* xfconf channel */
+ XfconfChannel *channel;
+
+ /* widgets */
+ GtkWidget *box;
+ GtkWidget *first_button;
+ GtkWidget *first_image;
+ GtkWidget *second_button;
+ GtkWidget *second_image;
+
+ /* settings */
+ ActionType first_action;
+ ActionType second_action;
+};
+
+enum
+{
+ PROP_0,
+ PROP_FIRST_ACTION,
+ PROP_SECOND_ACTION
+};
+
+static ActionEntry action_entries[] =
+{
+ { ACTION_DISABLED, N_("Disabled"),
+ NULL, NULL },
+ { ACTION_LOG_OUT_DIALOG, N_("Log Out Dialog"),
+ "system-log-out", "xfce4-session-logout" },
+ { ACTION_LOG_OUT, N_("Log Out"),
+ "system-log-out", "xfce4-session-logout --logout" },
+ { ACTION_LOCK_SCREEN, N_("Lock Screen"),
+ "system-lock-screen", "xflock4" },
+ { ACTION_SHUT_DOWN, N_("Shut Down"),
+ "system-shutdown", "xfce4-session-logout --halt" },
+ { ACTION_RESTART, N_("Restart"),
+ "xfsm-reboot", "xfce4-session-logout --reboot" },
+ { ACTION_SUSPEND, N_("Suspend"),
+ "system-suspend", "xfce4-session-logout --suspend" },
+ { ACTION_HIBERNATE, N_("Hibernate"),
+ "system-hibernate", "xfce4-session-logout --hibernate" }
+};
+
+
+
+/* define the plugin */
+XFCE_PANEL_DEFINE_PLUGIN (ActionsPlugin, actions_plugin)
+
+
+
+static void
+actions_plugin_class_init (ActionsPluginClass *klass)
+{
+ XfcePanelPluginClass *plugin_class;
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->set_property = actions_plugin_set_property;
+ gobject_class->get_property = actions_plugin_get_property;
+
+ plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
+ plugin_class->construct = actions_plugin_construct;
+ plugin_class->free_data = actions_plugin_free_data;
+ plugin_class->size_changed = actions_plugin_size_changed;
+ plugin_class->configure_plugin = actions_plugin_configure_plugin;
+ plugin_class->orientation_changed = actions_plugin_orientation_changed;
+
+ g_object_class_install_property (gobject_class,
+ PROP_FIRST_ACTION,
+ g_param_spec_uint ("first-action",
+ NULL, NULL,
+ ACTION_DISABLED,
+ ACTION_HIBERNATE - 1,
+ ACTION_LOG_OUT_DIALOG,
+ EXO_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_SECOND_ACTION,
+ g_param_spec_uint ("second-action",
+ NULL, NULL,
+ ACTION_DISABLED,
+ ACTION_HIBERNATE,
+ ACTION_DISABLED,
+ EXO_PARAM_READWRITE));
+}
+
+
+
+static void
+actions_plugin_init (ActionsPlugin *plugin)
+{
+ GtkWidget *widget;
+ ActionEntry *entry = &action_entries[ACTION_LOG_OUT_DIALOG];
+
+ /* initialize */
+ plugin->first_action = ACTION_LOG_OUT_DIALOG;
+ plugin->second_action = ACTION_DISABLED;
+
+ /* show the properties dialog */
+ xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
+
+ /* initialize xfconf */
+ xfconf_init (NULL);
+
+ plugin->box = xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (plugin), plugin->box);
+
+ plugin->first_button = widget = xfce_panel_create_button ();
+ gtk_box_pack_start (GTK_BOX (plugin->box), widget, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (widget), "clicked",
+ G_CALLBACK (actions_plugin_button_clicked), plugin);
+ gtk_widget_set_tooltip_text (widget, _(entry->title));
+ xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), widget);
+ gtk_widget_show (widget);
+
+ plugin->first_image = xfce_scaled_image_new_from_icon_name (entry->icon_name);
+ gtk_container_add (GTK_CONTAINER (widget), plugin->first_image);
+ gtk_widget_show (plugin->first_image);
+
+ plugin->second_button = widget = xfce_panel_create_button ();
+ gtk_box_pack_start (GTK_BOX (plugin->box), widget, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (widget), "clicked",
+ G_CALLBACK (actions_plugin_button_clicked), plugin);
+ xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), widget);
+
+ plugin->second_image = xfce_scaled_image_new ();
+ gtk_container_add (GTK_CONTAINER (widget), plugin->second_image);
+ gtk_widget_show (plugin->second_image);
+}
+
+
+
+static void
+actions_plugin_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (object);
+
+ switch (prop_id)
+ {
+ case PROP_FIRST_ACTION:
+ g_value_set_uint (value, plugin->first_action - 1);
+ break;
+
+ case PROP_SECOND_ACTION:
+ g_value_set_uint (value, plugin->second_action);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+actions_plugin_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (object);
+ ActionType action;
+
+ switch (prop_id)
+ {
+ case PROP_FIRST_ACTION:
+ /* set new value and update icon */
+ action = plugin->first_action = g_value_get_uint (value) + 1;
+ gtk_widget_set_tooltip_text (plugin->first_button,
+ _(action_entries[action].title));
+ xfce_scaled_image_set_from_icon_name (
+ XFCE_SCALED_IMAGE (plugin->first_image),
+ action_entries[action].icon_name);
+ break;
+
+ case PROP_SECOND_ACTION:
+ /* set new value */
+ action = plugin->second_action = g_value_get_uint (value);
+
+ /* update button visibility and icon */
+ if (action == ACTION_DISABLED)
+ {
+ gtk_widget_hide (plugin->second_button);
+ }
+ else
+ {
+ gtk_widget_show (plugin->second_button);
+ gtk_widget_set_tooltip_text (plugin->second_button,
+ _(action_entries[action].title));
+ xfce_scaled_image_set_from_icon_name (
+ XFCE_SCALED_IMAGE (plugin->second_image),
+ action_entries[action].icon_name);
+ }
+
+ /* update plugin size */
+ actions_plugin_size_changed (XFCE_PANEL_PLUGIN (plugin),
+ xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
+
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+actions_plugin_construct (XfcePanelPlugin *panel_plugin)
+{
+ ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (panel_plugin);
+
+ /* set the xfconf channel */
+ plugin->channel = xfce_panel_plugin_xfconf_channel_new (panel_plugin);
+
+ /* bind properties */
+ xfconf_g_property_bind (plugin->channel, "/first-action",
+ G_TYPE_UINT, plugin, "first-action");
+ xfconf_g_property_bind (plugin->channel, "/second-action",
+ G_TYPE_UINT, plugin, "second-action");
+
+ /* set orientation and size */
+ actions_plugin_orientation_changed (panel_plugin,
+ xfce_panel_plugin_get_orientation (panel_plugin));
+
+ /* show the plugin */
+ gtk_widget_show (plugin->box);
+}
+
+
+
+static void
+actions_plugin_free_data (XfcePanelPlugin *panel_plugin)
+{
+ ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (panel_plugin);
+
+ panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
+
+ /* release the xfonf channel */
+ g_object_unref (G_OBJECT (plugin->channel));
+
+ /* shutdown xfconf */
+ xfconf_shutdown ();
+}
+
+
+
+static gboolean
+actions_plugin_size_changed (XfcePanelPlugin *panel_plugin,
+ gint size)
+{
+ ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (panel_plugin);
+ gint width, height;
+
+ /* init size */
+ width = height = size;
+
+ if (plugin->second_action != ACTION_DISABLED)
+ {
+ if (xfce_panel_plugin_get_orientation (panel_plugin) ==
+ GTK_ORIENTATION_HORIZONTAL)
+ width /= 2;
+ else
+ height /= 2;
+ }
+
+ /* set the plugin size */
+ gtk_widget_set_size_request (GTK_WIDGET (panel_plugin),
+ width, height);
+
+ return TRUE;
+}
+
+
+
+static void
+actions_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
+{
+ ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (panel_plugin);
+ GtkBuilder *builder;
+ GObject *dialog;
+ GObject *object;
+ guint i;
+
+ panel_return_if_fail (XFCE_IS_ACTIONS_PLUGIN (plugin));
+ panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
+
+ /* load the dialog from the glade file */
+ builder = gtk_builder_new ();
+ if (gtk_builder_add_from_string (builder, actions_dialog_glade,
+ actions_dialog_glade_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));
+ }
+}
+
+
+
+static void
+actions_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
+ GtkOrientation orientation)
+{
+ ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (panel_plugin);
+ GtkOrientation box_orientation;
+
+ /* box orientation is opposite to the panel orientation */
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ box_orientation = GTK_ORIENTATION_VERTICAL;
+ else
+ box_orientation = GTK_ORIENTATION_HORIZONTAL;
+
+ /* set orientation */
+ xfce_hvbox_set_orientation (XFCE_HVBOX (plugin->box), box_orientation);
+
+ /* update the plugin size */
+ actions_plugin_size_changed (panel_plugin,
+ xfce_panel_plugin_get_size (panel_plugin));
+}
+
+
+
+static void
+actions_plugin_button_clicked (GtkWidget *button,
+ ActionsPlugin *plugin)
+{
+ ActionType action;
+ GError *error = NULL;
+
+ panel_return_if_fail (XFCE_IS_ACTIONS_PLUGIN (plugin));
+
+ /* get the action to execute */
+ if (button == plugin->first_button)
+ action = plugin->first_action;
+ else
+ action = plugin->second_action;
+
+ /* spawn the command */
+ if (!g_spawn_command_line_async (action_entries[action].command, &error))
+ {
+ /* show error */
+ xfce_dialog_show_error (gtk_widget_get_screen (button),
+ error, _("Failed to execute command \"%s\""),
+ action_entries[action].command);
+ g_error_free (error);
+ }
+}
+
diff --git a/plugins/pager/pager.desktop.in.in b/plugins/actions/actions.desktop.in.in
similarity index 52%
copy from plugins/pager/pager.desktop.in.in
copy to plugins/actions/actions.desktop.in.in
index d71cda1..d61a774 100644
--- a/plugins/pager/pager.desktop.in.in
+++ b/plugins/actions/actions.desktop.in.in
@@ -1,9 +1,9 @@
[Xfce Panel]
Type=X-XFCE-PanelPlugin
Encoding=UTF-8
-_Name=Pager
-_Comment=Miniature view of all virtual desktops
-Icon=xfce4-workspaces
-X-XFCE-Module=pager
+_Name=Action Buttons
+_Comment=Log out, lock or other system actions
+Icon=system-log-out
+X-XFCE-Module=actions
X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins
X-XFCE-External=FALSE
diff --git a/plugins/actions/actions.h b/plugins/actions/actions.h
new file mode 100644
index 0000000..e239657
--- /dev/null
+++ b/plugins/actions/actions.h
@@ -0,0 +1,44 @@
+/* $Id$ */
+/*
+ * Copyright (c) 2005-2007 Jasper Huijsmans <jasper at xfce.org>
+ * Copyright (c) 2007-2009 Nick Schermer <nick at 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., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __ACTIONS_H__
+#define __ACTIONS_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ActionsPluginClass ActionsPluginClass;
+typedef struct _ActionsPlugin ActionsPlugin;
+
+#define XFCE_TYPE_ACTIONS_PLUGIN (actions_plugin_get_type ())
+#define XFCE_ACTIONS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_ACTIONS_PLUGIN, ActionsPlugin))
+#define XFCE_ACTIONS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_ACTIONS_PLUGIN, ActionsPluginClass))
+#define XFCE_IS_ACTIONS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_ACTIONS_PLUGIN))
+#define XFCE_IS_ACTIONS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_ACTIONS_PLUGIN))
+#define XFCE_ACTIONS_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_ACTIONS_PLUGIN, ActionsPluginClass))
+
+GType actions_plugin_get_type (void) G_GNUC_CONST;
+
+void actions_plugin_register_type (GTypeModule *type_module);
+
+G_END_DECLS
+
+#endif /* !__ACTIONS_H__ */
More information about the Xfce4-commits
mailing list