[Xfce4-commits] <xfce4-panel:master> Clock plugin: added a function to call a system clock config tool
Andrzej
noreply at xfce.org
Sun Mar 3 12:02:05 CET 2013
Updating branch refs/heads/master
to 7d6203b69bd776304825afcdc859f115c911d7cf (commit)
from 27ce25acc51153f3f8d3c70fb1018b9b1ad14e8a (commit)
commit 7d6203b69bd776304825afcdc859f115c911d7cf
Author: Andrzej <ndrwrdck at gmail.com>
Date: Mon Feb 25 01:40:30 2013 +0000
Clock plugin: added a function to call a system clock config tool
plugins/clock/clock-dialog.glade | 15 +++++------
plugins/clock/clock.c | 48 +++++++++++++++++++++++++++++++++++++-
2 files changed, 54 insertions(+), 9 deletions(-)
diff --git a/plugins/clock/clock-dialog.glade b/plugins/clock/clock-dialog.glade
index f200e47..301cb56 100644
--- a/plugins/clock/clock-dialog.glade
+++ b/plugins/clock/clock-dialog.glade
@@ -123,15 +123,14 @@
</object>
</child>
<child>
- <object class="GtkLabel" id="label10">
+ <object class="GtkButton" id="run-time-config-tool">
+ <property name="label" translatable="yes">_Run configuration tool</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">To change the system time and the default timezone use a Time and Date configuration tool provided with your system.</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">System time</property>
- <attributes>
- <attribute name="style" value="oblique"/>
- </attributes>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Alternatively, use a "date" utility to set your system time.</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
index 6ebc791..e6ba940 100644
--- a/plugins/clock/clock.c
+++ b/plugins/clock/clock.c
@@ -44,6 +44,8 @@
#include "clock-dialog_ui.h"
#define DEFAULT_TOOLTIP_FORMAT "%A %d %B %Y"
+/* Please adjust the following command to match your distribution */
+#define DEFAULT_TIME_CONFIG_TOOL "time-admin"
static void clock_plugin_get_property (GObject *object,
@@ -90,7 +92,8 @@ enum
PROP_MODE,
PROP_TOOLTIP_FORMAT,
PROP_COMMAND,
- PROP_ROTATE_VERTICALLY
+ PROP_ROTATE_VERTICALLY,
+ PROP_TIME_CONFIG_TOOL
};
typedef enum
@@ -130,6 +133,7 @@ struct _ClockPlugin
gchar *tooltip_format;
ClockTimeTimeout *tooltip_timeout;
+ gchar *time_config_tool;
ClockTime *time;
};
@@ -223,6 +227,12 @@ clock_plugin_class_init (ClockPluginClass *klass)
g_param_spec_string ("command",
NULL, NULL, NULL,
EXO_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_TIME_CONFIG_TOOL,
+ g_param_spec_string ("time-config-tool",
+ NULL, NULL, NULL,
+ EXO_PARAM_READWRITE));
}
@@ -235,6 +245,7 @@ clock_plugin_init (ClockPlugin *plugin)
plugin->tooltip_format = g_strdup (DEFAULT_TOOLTIP_FORMAT);
plugin->tooltip_timeout = NULL;
plugin->command = NULL;
+ plugin->time_config_tool = g_strdup (DEFAULT_TIME_CONFIG_TOOL);
plugin->rotate_vertically = TRUE;
plugin->time = clock_time_new ();
@@ -278,6 +289,10 @@ clock_plugin_get_property (GObject *object,
g_value_set_string (value, plugin->command);
break;
+ case PROP_TIME_CONFIG_TOOL:
+ g_value_set_string (value, plugin->time_config_tool);
+ break;
+
case PROP_ROTATE_VERTICALLY:
g_value_set_boolean (value, plugin->rotate_vertically);
break;
@@ -324,6 +339,11 @@ clock_plugin_set_property (GObject *object,
clock_plugin_hide_calendar (plugin);
break;
+ case PROP_TIME_CONFIG_TOOL:
+ g_free (plugin->time_config_tool);
+ plugin->time_config_tool = g_value_dup_string (value);
+ break;
+
case PROP_ROTATE_VERTICALLY:
rotate_vertically = g_value_get_boolean (value);
if (plugin->rotate_vertically != rotate_vertically)
@@ -777,6 +797,26 @@ clock_plugin_configure_plugin_free (gpointer user_data)
static void
+clock_plugin_configure_run_config_tool (GtkWidget *button,
+ ClockPlugin *plugin)
+{
+ GError *error = NULL;
+
+ panel_return_if_fail (XFCE_IS_CLOCK_PLUGIN (plugin));
+
+ if (!xfce_spawn_command_line_on_screen (gtk_widget_get_screen (button),
+ plugin->time_config_tool,
+ FALSE, FALSE, &error))
+ {
+ xfce_dialog_show_error
+ (NULL, error, _("Failed to execute command \"%s\"."), plugin->time_config_tool);
+ g_error_free (error);
+ }
+}
+
+
+
+static void
clock_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
{
ClockPlugin *plugin = XFCE_CLOCK_PLUGIN (panel_plugin);
@@ -799,7 +839,13 @@ clock_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
dialog->plugin = plugin;
dialog->builder = builder;
+ object = gtk_builder_get_object (builder, "run-time-config-tool");
+ panel_return_if_fail (GTK_IS_BUTTON (object));
+ g_signal_connect (G_OBJECT (object), "clicked",
+ G_CALLBACK (clock_plugin_configure_run_config_tool), plugin);
+
object = gtk_builder_get_object (builder, "timezone-name");
+ panel_return_if_fail (GTK_IS_ENTRY (object));
exo_mutual_binding_new (G_OBJECT (plugin->time), "timezone",
G_OBJECT (object), "text");
More information about the Xfce4-commits
mailing list