Updating branch refs/heads/master to 44ef2fa54ba164b9b434b01d82ca739b4b49a9ce (commit) from 02a4e03020680a20333035397f49f99186941635 (commit)
commit 44ef2fa54ba164b9b434b01d82ca739b4b49a9ce Author: Andrzej <ndrwr...@gmail.com> Date: Sun Apr 1 03:06:19 2012 +0900 Experiment with preferences dialog. Added an XfceIndicatorDialog class based on GtkBuilder. Added dependency on libxfce4ui (v.4.8 - not checked if earlier revisions work) The UI file (stub) was copied from the systray plugin. configure.in.in | 1 + panel-plugin/Makefile.am | 19 +++ panel-plugin/indicator-dialog.c | 172 ++++++++++++++++++++ panel-plugin/indicator-dialog.glade | 293 +++++++++++++++++++++++++++++++++++ panel-plugin/indicator-dialog.h | 43 +++++ panel-plugin/indicator.c | 26 +++- panel-plugin/indicator.h | 8 +- 7 files changed, 558 insertions(+), 4 deletions(-) diff --git a/configure.in.in b/configure.in.in index b308dbd..e2bdeaf 100644 --- a/configure.in.in +++ b/configure.in.in @@ -74,6 +74,7 @@ dnl *********************************** XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0]) XDT_CHECK_PACKAGE([EXO], [exo-1], [0.6.0]) XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.99.2]) +XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.8.0]) XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.2]) XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0]) XDT_CHECK_PACKAGE([INDICATOR], [indicator], [0.3.0], [indicator_pkgname=indicator], [XDT_CHECK_PACKAGE([INDICATOR], [indicator-0.4], [0.3.90], [indicator_pkgname=indicator-0.4], [])]) diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am index f0697e1..80c33f0 100644 --- a/panel-plugin/Makefile.am +++ b/panel-plugin/Makefile.am @@ -14,11 +14,17 @@ plugindir = \ plugin_LTLIBRARIES = \ libindicator-plugin.la +libindicator_built_sources = \ + indicator-dialog_ui.h + libindicator_plugin_la_SOURCES = \ + $(libindicator_built_sources) \ indicator-button.c \ indicator-button.h \ indicator-box.c \ indicator-box.h \ + indicator-dialog.c \ + indicator-dialog.h \ indicator.c \ indicator.h @@ -26,6 +32,7 @@ libindicator_plugin_la_CFLAGS = \ $(GTK_CFLAGS) \ $(EXO_CFLAGS) \ $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCE4UI_CFLAGS) \ $(LIBXFCE4PANEL_CFLAGS) \ $(XFCONF_CFLAGS) \ $(INDICATOR_CFLAGS) \ @@ -45,6 +52,7 @@ libindicator_plugin_la_LIBADD = \ $(GTK_LIBS) \ $(EXO_LIBS) \ $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCE4UI_LIBS) \ $(LIBXFCE4PANEL_LIBS) \ $(XFCONF_LIBS) \ $(INDICATOR_LIBS) @@ -69,4 +77,15 @@ EXTRA_DIST = \ DISTCLEANFILES = \ $(desktop_DATA) +if MAINTAINER_MODE +BUILT_SOURCES = \ + $(libindicator_built_sources) + +DISTCLEANFILES += \ + $(libindicator_built_sources) + +indicator-dialog_ui.h: indicator-dialog.glade + $(AM_V_GEN) exo-csource --static --strip-comments --strip-content --name=indicator_dialog_ui $< >$@ +endif + # vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/panel-plugin/indicator-dialog.c b/panel-plugin/indicator-dialog.c new file mode 100644 index 0000000..0ad6c04 --- /dev/null +++ b/panel-plugin/indicator-dialog.c @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2012 Andrzej <ndrwr...@gmail.com> + * + * 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 Library 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 + +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include <libxfce4util/libxfce4util.h> +#include <libxfce4ui/libxfce4ui.h> +#include <xfconf/xfconf.h> +#include <exo/exo.h> +#include <libxfce4panel/xfce-panel-plugin.h> + +#include "indicator.h" +#include "indicator-dialog.h" +#include "indicator-dialog_ui.h" + + + +static void indicator_dialog_build (IndicatorDialog *dialog, + IndicatorPlugin *plugin); +static void indicator_dialog_response (GtkWidget *window, + gint response_id, + IndicatorDialog *dialog); + + + +struct _IndicatorDialogClass +{ + GtkBuilderClass __parent__; +}; + +struct _IndicatorDialog +{ + GtkBuilder __parent__; + + GObject *dialog; + + XfconfChannel *channel; + + IndicatorPlugin *plugin; + + //GtkTreeSelection *selection; + + //gulong bindings[4]; + gulong property_watch_id; +}; + + + +G_DEFINE_TYPE (IndicatorDialog, indicator_dialog, GTK_TYPE_BUILDER) + + + +static void +indicator_dialog_class_init (IndicatorDialogClass *klass) +{ +} + + + +static void +indicator_dialog_init (IndicatorDialog *dialog) +{ +} + + + + +static void +indicator_dialog_build (IndicatorDialog *dialog, + IndicatorPlugin *plugin) +{ + GObject *object; + GError *error = NULL; + + dialog->channel = xfconf_channel_get ("xfce4-panel"); + dialog->plugin = plugin; + + if (xfce_titled_dialog_get_type () == 0) + return; + + /* load the builder data into the object */ + if (gtk_builder_add_from_string (GTK_BUILDER (dialog), indicator_dialog_ui, + indicator_dialog_ui_length, &error)) + { + + dialog->dialog = gtk_builder_get_object (GTK_BUILDER (dialog), "dialog"); + g_return_if_fail (XFCE_IS_TITLED_DIALOG (dialog->dialog)); + g_signal_connect (G_OBJECT (dialog->dialog), "response", + G_CALLBACK (indicator_dialog_response), dialog); + + object = gtk_builder_get_object (GTK_BUILDER (dialog), "size-max"); + g_return_if_fail (GTK_IS_WIDGET (object)); + exo_mutual_binding_new (G_OBJECT (indicator_get_buttonbox (plugin)), "icon-size-max", + G_OBJECT (object), "value"); + } + else + { + g_critical ("Faild to construct the builder: %s.", + error->message); + g_error_free (error); + } +} + + +static void +indicator_dialog_response (GtkWidget *window, + gint response_id, + IndicatorDialog *dialog) +{ + g_return_if_fail (GTK_IS_DIALOG (window)); + g_return_if_fail (XFCE_IS_INDICATOR_DIALOG (dialog)); + + if (response_id == GTK_RESPONSE_HELP) + { + xfce_dialog_show_help (GTK_WINDOW (window), "xfce4-indicator", "dialog", NULL); + } + else + { + g_signal_handler_disconnect (dialog->channel, dialog->property_watch_id); + + gtk_widget_destroy (window); + + g_object_unref (G_OBJECT (dialog)); + } +} + + + +void +indicator_dialog_show (GdkScreen *screen, + IndicatorPlugin *plugin) +{ + static IndicatorDialog *dialog = NULL; + + g_return_if_fail (GDK_IS_SCREEN (screen)); + g_return_if_fail (XFCE_IS_INDICATOR_PLUGIN (plugin)); + + if (dialog == NULL) + { + dialog = g_object_new (XFCE_TYPE_INDICATOR_DIALOG, NULL); + g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &dialog); + indicator_dialog_build (XFCE_INDICATOR_DIALOG (dialog), plugin); + gtk_widget_show (GTK_WIDGET (dialog->dialog)); + } + else + { + gtk_window_present (GTK_WINDOW (dialog->dialog)); + } + + gtk_window_set_screen (GTK_WINDOW (dialog->dialog), screen); +} diff --git a/panel-plugin/indicator-dialog.glade b/panel-plugin/indicator-dialog.glade new file mode 100644 index 0000000..7c715a4 --- /dev/null +++ b/panel-plugin/indicator-dialog.glade @@ -0,0 +1,293 @@ +<?xml version="1.0"?> +<interface> + <requires lib="gtk+" version="2.14"/> + <!-- interface-requires libxfce4ui 0.0 --> + <!-- interface-naming-policy toplevel-contextual --> + <object class="GtkListStore" id="applications-store"> + <columns> + <!-- column-name icon --> + <column type="GdkPixbuf"/> + <!-- column-name title --> + <column type="gchararray"/> + <!-- column-name hidden --> + <column type="gboolean"/> + <!-- column-name internal-name --> + <column type="gchararray"/> + </columns> + </object> + <object class="XfceTitledDialog" id="dialog"> + <property name="title" translatable="yes">Indicators</property> + <property name="default_width">325</property> + <property name="default_height">425</property> + <property name="icon_name">gtk-properties</property> + <property name="type_hint">normal</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox2"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="border_width">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkFrame" id="frame3"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="left_padding">12</property> + <child> + <object class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="border_width">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Maximum icon size (px):</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">size-max</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="size-max"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">size-adjustment</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="show-frame"> + <property name="label" translatable="yes">Show _frame</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Appearance</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="left_padding">12</property> + <child> + <object class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="border_width">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="applications-treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">applications-store</property> + <property name="headers_clickable">False</property> + <property name="rules_hint">True</property> + <property name="enable_search">False</property> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <property name="min_width">24</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <property name="title">Application</property> + <property name="expand">True</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <property name="title">Hidden</property> + <child> + <object class="GtkCellRendererToggle" id="hidden-toggle"/> + <attributes> + <attribute name="active">2</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHButtonBox" id="hbuttonbox1"> + <property name="visible">True</property> + <property name="layout_style">start</property> + <child> + <object class="GtkButton" id="applications-clear"> + <property name="label" translatable="yes">C_lear Known Applications</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image1</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Known Applications</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area2"> + <property name="visible">True</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="close-button"> + <property name="label">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="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help-button"> + <property name="label">gtk-help</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="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + <property name="secondary">True</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-widget response="0">help-button</action-widget> + </action-widgets> + </object> + <object class="GtkAdjustment" id="size-adjustment"> + <property name="value">32</property> + <property name="lower">12</property> + <property name="upper">64</property> + <property name="step_increment">1</property> + <property name="page_increment">2</property> + </object> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="stock">gtk-clear</property> + </object> +</interface> diff --git a/panel-plugin/indicator-dialog.h b/panel-plugin/indicator-dialog.h new file mode 100644 index 0000000..fe6cf04 --- /dev/null +++ b/panel-plugin/indicator-dialog.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2012 Andrzej <ndrwr...@gmail.com> + * + * 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 Library 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 __INDICATOR_DIALOG_H__ +#define __INDICATOR_DIALOG_H__ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +typedef struct _IndicatorDialogClass IndicatorDialogClass; +typedef struct _IndicatorDialog IndicatorDialog; + +#define XFCE_TYPE_INDICATOR_DIALOG (indicator_dialog_get_type ()) +#define XFCE_INDICATOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_INDICATOR_DIALOG, IndicatorDialog)) +#define XFCE_INDICATOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_INDICATOR_DIALOG, IndicatorDialogClass)) +#define XFCE_IS_INDICATOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_INDICATOR_DIALOG)) +#define XFCE_IS_INDICATOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_INDICATOR_DIALOG)) +#define XFCE_INDICATOR_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_INDICATOR_DIALOG, IndicatorDialogClass)) + +GType indicator_dialog_get_type (void) G_GNUC_CONST; + +void indicator_dialog_show (GdkScreen *screen, + IndicatorPlugin *plugin); + +G_END_DECLS + +#endif /* !__INDICATOR_DIALOG_H__ */ diff --git a/panel-plugin/indicator.c b/panel-plugin/indicator.c index ff1bd29..c51603e 100644 --- a/panel-plugin/indicator.c +++ b/panel-plugin/indicator.c @@ -31,6 +31,7 @@ #include "indicator.h" #include "indicator-box.h" #include "indicator-button.h" +#include "indicator-dialog.h" #define DEFAULT_EXCLUDED_MODULES NULL @@ -45,6 +46,7 @@ static void indicator_construct (XfcePanelPlu static void indicator_free (XfcePanelPlugin *plugin); static gboolean load_module (const gchar *name, IndicatorPlugin *indicator); +static void indicator_configure_plugin (XfcePanelPlugin *plugin); static gboolean indicator_size_changed (XfcePanelPlugin *plugin, gint size); #ifdef HAS_PANEL_49 @@ -150,7 +152,7 @@ indicator_class_init (IndicatorPluginClass *klass) plugin_class->construct = indicator_construct; plugin_class->free_data = indicator_free; plugin_class->size_changed = indicator_size_changed; - //plugin_class->configure_plugin = indicator_configure_plugin; + plugin_class->configure_plugin = indicator_configure_plugin; #ifdef HAS_PANEL_49 plugin_class->mode_changed = indicator_mode_changed; #else @@ -251,6 +253,17 @@ indicator_free (XfcePanelPlugin *plugin) +static void +indicator_configure_plugin (XfcePanelPlugin *plugin) +{ + g_return_if_fail (XFCE_IS_INDICATOR_PLUGIN (plugin)); + + indicator_dialog_show (gtk_widget_get_screen (GTK_WIDGET (plugin)), XFCE_INDICATOR_PLUGIN (plugin)); +} + + + + #ifdef HAS_PANEL_49 static void indicator_mode_changed (XfcePanelPlugin *plugin, @@ -337,6 +350,8 @@ indicator_construct (XfcePanelPlugin *plugin) { IndicatorPlugin *indicator = XFCE_INDICATOR_PLUGIN (plugin); + xfce_panel_plugin_menu_show_configure (plugin); + //consider moving some stuff from indicator_init() here } @@ -431,3 +446,12 @@ load_module (const gchar * name, IndicatorPlugin * indicator) return TRUE; } + + +XfceIndicatorBox * +indicator_get_buttonbox (IndicatorPlugin *plugin) +{ + g_return_val_if_fail (XFCE_IS_INDICATOR_PLUGIN (plugin), NULL); + + return plugin->buttonbox; +} diff --git a/panel-plugin/indicator.h b/panel-plugin/indicator.h index b59c963..dfe2b47 100644 --- a/panel-plugin/indicator.h +++ b/panel-plugin/indicator.h @@ -21,6 +21,7 @@ #include <glib.h> #include <gtk/gtk.h> #include <libxfce4panel/libxfce4panel.h> +#include "indicator-box.h" G_BEGIN_DECLS typedef struct _IndicatorPluginClass IndicatorPluginClass; @@ -41,9 +42,10 @@ void indicator_register_type (XfcePanelTypeModule *type_module); #define INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED "scroll-entry" #endif -void -indicator_save (XfcePanelPlugin *plugin, - IndicatorPlugin *indicator); +void indicator_save (XfcePanelPlugin *plugin, + IndicatorPlugin *indicator); + +XfceIndicatorBox *indicator_get_buttonbox (IndicatorPlugin *plugin); G_END_DECLS _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits