[Xfce4-commits] <xfce4-panel:devel> Attach help buttons to manual pages.
Nick Schermer
noreply at xfce.org
Mon Feb 22 20:10:03 CET 2010
Updating branch refs/heads/devel
to c3036a2852069e8e817b15eaa1f0aa50765a8b38 (commit)
from 527c44b6d809f3cdc3a3727c3ba43b11fa62ad13 (commit)
commit c3036a2852069e8e817b15eaa1f0aa50765a8b38
Author: Nick Schermer <nick at xfce.org>
Date: Mon Feb 22 20:00:56 2010 +0100
Attach help buttons to manual pages.
common/Makefile.am | 7 +-
common/panel-builder.c | 98 +++++++++++++++++++-
common/panel-builder.h | 12 ++-
panel/panel-item-dialog.c | 12 +--
panel/panel-preferences-dialog.c | 16 +---
plugins/actions/actions-dialog.glade | 16 +++
.../applicationsmenu/applicationsmenu-dialog.glade | 16 +++
plugins/clock/clock-dialog.glade | 16 +++
plugins/directorymenu/directorymenu-dialog.glade | 22 ++++-
plugins/launcher/launcher-dialog.glade | 4 +-
plugins/pager/pager-dialog.glade | 16 +++
plugins/separator/separator-dialog.glade | 16 +++
plugins/systray/systray-dialog.glade | 16 +++
plugins/tasklist/tasklist-dialog.glade | 16 +++
plugins/windowmenu/windowmenu-dialog.glade | 16 +++
po/POTFILES.in | 2 +
16 files changed, 266 insertions(+), 35 deletions(-)
diff --git a/common/Makefile.am b/common/Makefile.am
index ae2ec96..331e57f 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -3,6 +3,7 @@ INCLUDES = \
-I$(top_srcdir) \
-DG_LOG_DOMAIN=\"libpanel-common\" \
-DLIBXFCE4PANEL_COMPILATION \
+ -DHELPDIR=\"$(docdir)/html\" \
$(PLATFORM_CPPFLAGS)
noinst_LTLIBRARIES = \
@@ -19,6 +20,8 @@ libpanel_common_la_SOURCES = \
libpanel_common_la_CFLAGS = \
$(XFCONF_CFLAGS) \
$(GTK_CFLAGS) \
+ $(EXO_CFLAGS) \
+ $(LIBXFCE4UI_CFLAGS) \
$(PLATFORM_CFLAGS)
libpanel_common_la_LDFLAGS = \
@@ -27,7 +30,9 @@ libpanel_common_la_LDFLAGS = \
libpanel_common_la_LIBADD = \
$(XFCONF_LIBS) \
- $(GTK_LIBS)
+ $(GTK_LIBS) \
+ $(LIBXFCE4UI_LIBS) \
+ $(EXO_LIBS)
EXTRA_DIST = \
panel-dbus.h \
diff --git a/common/panel-builder.c b/common/panel-builder.c
index 312bde7..40a5f41 100644
--- a/common/panel-builder.c
+++ b/common/panel-builder.c
@@ -20,11 +20,35 @@
#include <config.h>
#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+#include <libxfce4ui/libxfce4ui.h>
+#include <exo/exo.h>
+
#include <common/panel-private.h>
#include <common/panel-builder.h>
+static void
+panel_builder_help_button_clicked (GtkWidget *button,
+ XfcePanelPlugin *panel_plugin)
+{
+ GtkWidget *toplevel;
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (panel_plugin));
+ panel_return_if_fail (GTK_IS_WIDGET (button));
+
+ toplevel = gtk_widget_get_toplevel (button);
+ panel_builder_show_help (GTK_WINDOW (toplevel),
+ xfce_panel_plugin_get_name (panel_plugin),
+ "properties");
+}
+
+
+
GtkBuilder *
panel_builder_new (XfcePanelPlugin *panel_plugin,
const gchar *buffer,
@@ -55,7 +79,12 @@ panel_builder_new (XfcePanelPlugin *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);
+ G_CALLBACK (gtk_widget_destroy), dialog);
+
+ button = gtk_builder_get_object (builder, "help-button");
+ if (G_LIKELY (button != NULL))
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (panel_builder_help_button_clicked), panel_plugin);
if (G_LIKELY (dialog_return != NULL))
*dialog_return = dialog;
@@ -78,3 +107,70 @@ panel_builder_new (XfcePanelPlugin *panel_plugin,
return NULL;
}
+
+
+void
+panel_builder_show_help (GtkWindow *parent,
+ const gchar *page,
+ const gchar *offset)
+{
+ GdkScreen *screen;
+ gchar *filename;
+ gchar *uri = NULL;
+ GError *error = NULL;
+ gchar *locale;
+ gboolean exists;
+
+ panel_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
+ if (G_LIKELY (parent != NULL))
+ screen = gtk_window_get_screen (parent);
+ else
+ screen = gdk_screen_get_default ();
+
+ if (page == NULL)
+ page = "index";
+
+ /* get the locale of the user */
+ locale = g_strdup (setlocale (LC_MESSAGES, NULL));
+ if (G_LIKELY (locale != NULL))
+ locale = g_strdelimit (locale, "._", '\0');
+ else
+ locale = g_strdup ("C");
+
+ /* check if the help page exists on the system */
+ filename = g_strconcat (HELPDIR, G_DIR_SEPARATOR_S, locale,
+ G_DIR_SEPARATOR_S, page, ".html", NULL);
+ exists = g_file_test (filename, G_FILE_TEST_EXISTS);
+ if (!exists)
+ {
+ g_free (filename);
+ filename = g_strconcat (HELPDIR, G_DIR_SEPARATOR_S "C"
+ G_DIR_SEPARATOR_S, page, ".html", NULL);
+ exists = g_file_test (filename, G_FILE_TEST_EXISTS);
+ }
+
+ if (G_LIKELY (exists))
+ uri = g_strconcat ("file://", filename, "#", offset, NULL);
+ else if (xfce_dialog_confirm (parent, GTK_STOCK_HELP, _("_Read Online"),
+ _("You can read the user manual online. This manual may however "
+ "not exactly match your panel version."),
+ _("The Xfce Panel user manual is not installed on your computer")))
+ uri = g_strconcat ("http://foo-projects.org/~nick/docs/xfce4-panel/?lang=",
+ locale, "&page=", page, "&offset=", offset, NULL);
+
+ g_free (filename);
+ g_free (locale);
+
+ /* try to run the documentation browser */
+ if (uri != NULL
+ && !exo_execute_preferred_application_on_screen ("WebBrowser", uri, NULL,
+ NULL, screen, &error))
+ {
+ /* display an error message to the user */
+ xfce_dialog_show_error (parent, error, _("Failed to open the documentation browser"));
+ g_error_free (error);
+ }
+
+ g_free (uri);
+}
diff --git a/common/panel-builder.h b/common/panel-builder.h
index 553b800..d53f3dd 100644
--- a/common/panel-builder.h
+++ b/common/panel-builder.h
@@ -27,9 +27,13 @@
if (xfce_titled_dialog_get_type () == 0) \
return;
-GtkBuilder *panel_builder_new (XfcePanelPlugin *panel_plugin,
- const gchar *buffer,
- gsize length,
- GObject **dialog_return) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+GtkBuilder *panel_builder_new (XfcePanelPlugin *panel_plugin,
+ const gchar *buffer,
+ gsize length,
+ GObject **dialog_return) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+void panel_builder_show_help (GtkWindow *parent,
+ const gchar *page,
+ const gchar *offset);
#endif /* !__PANEL_BUILDER_H__ */
diff --git a/panel/panel-item-dialog.c b/panel/panel-item-dialog.c
index f2b5545..86158f6 100644
--- a/panel/panel-item-dialog.c
+++ b/panel/panel-item-dialog.c
@@ -29,6 +29,7 @@
#include <libxfce4util/libxfce4util.h>
#include <common/panel-private.h>
+#include <common/panel-builder.h>
#include <libxfce4panel/libxfce4panel.h>
#include <panel/panel-application.h>
@@ -291,9 +292,7 @@ static void
panel_item_dialog_response (GtkDialog *gtk_dialog,
gint response_id)
{
- GError *error = NULL;
PanelItemDialog *dialog = PANEL_ITEM_DIALOG (gtk_dialog);
- GdkScreen *screen;
PanelModule *module;
panel_return_if_fail (PANEL_IS_ITEM_DIALOG (dialog));
@@ -302,14 +301,7 @@ panel_item_dialog_response (GtkDialog *gtk_dialog,
if (response_id == GTK_RESPONSE_HELP)
{
- screen = gtk_widget_get_screen (GTK_WIDGET (gtk_dialog));
- if (!gtk_show_uri (screen, ITEMS_HELP_URL,
- gtk_get_current_event_time (), &error))
- {
- xfce_dialog_show_error (GTK_WINDOW (gtk_dialog), error,
- _("Failed to open manual"));
- g_error_free (error);
- }
+ panel_builder_show_help (GTK_WINDOW (gtk_dialog), "add-new-items", NULL);
}
else if (response_id == GTK_RESPONSE_OK)
{
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index d93b84b..65b8e44 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -25,6 +25,7 @@
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-private.h>
+#include <common/panel-builder.h>
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4panel/xfce-panel-plugin-provider.h>
@@ -262,25 +263,12 @@ panel_preferences_dialog_response (GtkWidget *window,
gint response_id,
PanelPreferencesDialog *dialog)
{
- GError *error = NULL;
- GdkScreen *screen;
-
panel_return_if_fail (GTK_IS_DIALOG (window));
panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog));
if (G_UNLIKELY (response_id == 1))
{
- /* get the dialog screen */
- screen = gtk_widget_get_screen (window);
-
- /* open the help url */
- if (!gtk_show_uri (screen, PREFERENCES_HELP_URL,
- gtk_get_current_event_time (), &error))
- {
- xfce_dialog_show_error (GTK_WINDOW (window), error,
- _("Failed to open manual"));
- g_error_free (error);
- }
+ panel_builder_show_help (GTK_WINDOW (window), "preferences", NULL);
}
else
{
diff --git a/plugins/actions/actions-dialog.glade b/plugins/actions/actions-dialog.glade
index b015930..d32d6af 100644
--- a/plugins/actions/actions-dialog.glade
+++ b/plugins/actions/actions-dialog.glade
@@ -130,6 +130,21 @@
<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>
@@ -141,6 +156,7 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="first-action-model">
diff --git a/plugins/applicationsmenu/applicationsmenu-dialog.glade b/plugins/applicationsmenu/applicationsmenu-dialog.glade
index 8220535..052f926 100644
--- a/plugins/applicationsmenu/applicationsmenu-dialog.glade
+++ b/plugins/applicationsmenu/applicationsmenu-dialog.glade
@@ -286,6 +286,21 @@
<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>
@@ -297,6 +312,7 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkSizeGroup" id="sizegroup1"/>
diff --git a/plugins/clock/clock-dialog.glade b/plugins/clock/clock-dialog.glade
index 0301eef..b3451eb 100644
--- a/plugins/clock/clock-dialog.glade
+++ b/plugins/clock/clock-dialog.glade
@@ -383,6 +383,21 @@
<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>
@@ -394,6 +409,7 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="mode-model">
diff --git a/plugins/directorymenu/directorymenu-dialog.glade b/plugins/directorymenu/directorymenu-dialog.glade
index 934a215..9b268b0 100644
--- a/plugins/directorymenu/directorymenu-dialog.glade
+++ b/plugins/directorymenu/directorymenu-dialog.glade
@@ -39,8 +39,8 @@
<child>
<object class="GtkFileChooserButton" id="base-directory">
<property name="visible">True</property>
- <property name="action">select-folder</property>
<property name="local_only">False</property>
+ <property name="action">select-folder</property>
<property name="title" translatable="yes">Select A Directory</property>
</object>
<packing>
@@ -212,6 +212,21 @@
<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>
@@ -223,13 +238,14 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkSizeGroup" id="sizegroup1">
<widgets>
- <widget name="label7"/>
- <widget name="label2"/>
<widget name="label4"/>
+ <widget name="label2"/>
+ <widget name="label7"/>
</widgets>
</object>
</interface>
diff --git a/plugins/launcher/launcher-dialog.glade b/plugins/launcher/launcher-dialog.glade
index 316d1a3..9032e49 100644
--- a/plugins/launcher/launcher-dialog.glade
+++ b/plugins/launcher/launcher-dialog.glade
@@ -368,7 +368,7 @@
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="button1">
+ <object class="GtkButton" id="help-button">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -406,7 +406,7 @@
</object>
</child>
<action-widgets>
- <action-widget response="1">button1</action-widget>
+ <action-widget response="1">help-button</action-widget>
<action-widget response="0">button2</action-widget>
</action-widgets>
</object>
diff --git a/plugins/pager/pager-dialog.glade b/plugins/pager/pager-dialog.glade
index 045124a..9dc1510 100644
--- a/plugins/pager/pager-dialog.glade
+++ b/plugins/pager/pager-dialog.glade
@@ -187,6 +187,21 @@
<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>
@@ -198,6 +213,7 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkImage" id="image1">
diff --git a/plugins/separator/separator-dialog.glade b/plugins/separator/separator-dialog.glade
index 4ab3e17..ad19aff 100644
--- a/plugins/separator/separator-dialog.glade
+++ b/plugins/separator/separator-dialog.glade
@@ -117,6 +117,21 @@
<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>
@@ -128,6 +143,7 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="style-model">
diff --git a/plugins/systray/systray-dialog.glade b/plugins/systray/systray-dialog.glade
index b41a25a..851f4c3 100644
--- a/plugins/systray/systray-dialog.glade
+++ b/plugins/systray/systray-dialog.glade
@@ -253,6 +253,21 @@
<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>
@@ -264,6 +279,7 @@
</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="rows-adjustment">
diff --git a/plugins/tasklist/tasklist-dialog.glade b/plugins/tasklist/tasklist-dialog.glade
index 7947788..a2e19a0 100644
--- a/plugins/tasklist/tasklist-dialog.glade
+++ b/plugins/tasklist/tasklist-dialog.glade
@@ -310,6 +310,21 @@
<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>
@@ -321,6 +336,7 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="grouping-model">
diff --git a/plugins/windowmenu/windowmenu-dialog.glade b/plugins/windowmenu/windowmenu-dialog.glade
index 6b196c7..e430b2f 100644
--- a/plugins/windowmenu/windowmenu-dialog.glade
+++ b/plugins/windowmenu/windowmenu-dialog.glade
@@ -199,6 +199,21 @@
<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>
@@ -210,6 +225,7 @@
</child>
<action-widgets>
<action-widget response="0">close-button</action-widget>
+ <action-widget response="0">help-button</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="style-model">
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1845f53..dd9ae8a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,8 @@
panel-desktop-handler.desktop.in
panel-preferences.desktop.in
+common/panel-builder.c
+
libxfce4panel/libxfce4panel.h
libxfce4panel/libxfce4panel-enums.h
libxfce4panel/xfce-arrow-button.c
More information about the Xfce4-commits
mailing list