Browse Source

Attach help buttons to manual pages.

upstream/xfce4-panel-4.10.1
Nick Schermer 13 years ago
parent
commit
b9707f36c9
  1. 7
      common/Makefile.am
  2. 98
      common/panel-builder.c
  3. 12
      common/panel-builder.h
  4. 12
      panel/panel-item-dialog.c
  5. 16
      panel/panel-preferences-dialog.c
  6. 16
      plugins/actions/actions-dialog.glade
  7. 16
      plugins/applicationsmenu/applicationsmenu-dialog.glade
  8. 16
      plugins/clock/clock-dialog.glade
  9. 22
      plugins/directorymenu/directorymenu-dialog.glade
  10. 4
      plugins/launcher/launcher-dialog.glade
  11. 16
      plugins/pager/pager-dialog.glade
  12. 16
      plugins/separator/separator-dialog.glade
  13. 16
      plugins/systray/systray-dialog.glade
  14. 16
      plugins/tasklist/tasklist-dialog.glade
  15. 16
      plugins/windowmenu/windowmenu-dialog.glade
  16. 2
      po/POTFILES.in

7
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 \

98
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);
}

12
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__ */

12
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)
{

16
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
{

16
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">

16
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"/>

16
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">

22
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>

4
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>

16
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">

16
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">

16
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">

16
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">

16
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">

2
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

Loading…
Cancel
Save