[Goodies-commits] r7069 - in xfce4-clipman-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Tue Mar 31 23:10:30 CEST 2009
Author: mmassonnet
Date: 2009-03-31 21:10:29 +0000 (Tue, 31 Mar 2009)
New Revision: 7069
Modified:
xfce4-clipman-plugin/trunk/ChangeLog
xfce4-clipman-plugin/trunk/TODO
xfce4-clipman-plugin/trunk/panel-plugin/panel-plugin.c
xfce4-clipman-plugin/trunk/panel-plugin/settings-dialog.glade
Log:
Set sensitivity of OK button in actions dialog
Modified: xfce4-clipman-plugin/trunk/ChangeLog
===================================================================
--- xfce4-clipman-plugin/trunk/ChangeLog 2009-03-31 20:57:54 UTC (rev 7068)
+++ xfce4-clipman-plugin/trunk/ChangeLog 2009-03-31 21:10:29 UTC (rev 7069)
@@ -1,4 +1,24 @@
2009-03-31 Mike Massonnet
+Set sensitivity of OK button in actions dialog
+
+ - panel-plugin/panel-plugin.c(panel_plugin_configure):
+ Put the actions dialog in the same window group as the settings dialog
+ to respect the its modal state.
+ - panel-plugin/panel-plugin;c(panel_plugin_configure):
+ Connect action-name, regex, and buttons add-command/delete-command to
+ the new callback cb_set_action_dialog_button_ok to set automatically
+ the sensitivity of the OK button in the actions dialog.
+ - panel-plugin/panel-plugin.c(cb_actions_row_activated):
+ Set the text after the commands in the treeview so it updates the OK
+ button accordingly wrt to the entry text changes.
+ - panel-plugin/panel-plugin.c(cb_add_command):
+ Fix the condition to add a new command and do the same check in
+ cb_refresh_command.
+ - panel-plugin/panel-plugin.c(cb_set_action_dialog_button_ok):
+ Verify that there is a command-name, a valid regex, and at least one
+ command and set the OK button sensitive, otherwise not.
+
+2009-03-31 Mike Massonnet
Make Clipman the owner of the clipboard contents
- panel-plugin/collector.c:
Modified: xfce4-clipman-plugin/trunk/TODO
===================================================================
--- xfce4-clipman-plugin/trunk/TODO 2009-03-31 20:57:54 UTC (rev 7068)
+++ xfce4-clipman-plugin/trunk/TODO 2009-03-31 21:10:29 UTC (rev 7069)
@@ -1,3 +1,2 @@
Actions:
-- Set sensitivity of "ok" button in the actions settings dialogs
- A regex validator dialog
Modified: xfce4-clipman-plugin/trunk/panel-plugin/panel-plugin.c
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/panel-plugin.c 2009-03-31 20:57:54 UTC (rev 7068)
+++ xfce4-clipman-plugin/trunk/panel-plugin/panel-plugin.c 2009-03-31 21:10:29 UTC (rev 7069)
@@ -127,6 +127,8 @@
MyPlugin *plugin);
static void cb_delete_command (GtkButton *button,
MyPlugin *plugin);
+static void cb_set_action_dialog_button_ok (GtkWidget *widget,
+ MyPlugin *plugin);
@@ -230,6 +232,7 @@
MyPlugin *plugin)
{
GtkWidget *dialog;
+ GtkWidget *action_dialog;
GtkWindowGroup *group;
/* GladeXML */
@@ -241,6 +244,10 @@
group = gtk_window_group_new ();
gtk_window_group_add_window (group, GTK_WINDOW (dialog));
+ /* Action dialog */
+ action_dialog = glade_xml_get_widget (plugin->gxml, "action-dialog");
+ gtk_window_group_add_window (group, GTK_WINDOW (action_dialog));
+
/* General settings */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (plugin->gxml, "save-on-quit")),
DEFAULT_SAVE_ON_QUIT);
@@ -259,7 +266,7 @@
xfconf_g_property_bind (plugin->channel, "/settings/max-texts-in-history", G_TYPE_UINT,
G_OBJECT (glade_xml_get_widget (plugin->gxml, "max-texts-in-history")), "value");
- /* Actions */
+ /* Actions tab and dialog */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (plugin->gxml, "enable-actions")),
DEFAULT_ENABLE_ACTIONS);
xfconf_g_property_bind (plugin->channel, "/settings/enable-actions", G_TYPE_BOOLEAN,
@@ -276,11 +283,22 @@
setup_actions_treeview (GTK_TREE_VIEW (glade_xml_get_widget (plugin->gxml, "actions")), plugin);
setup_commands_treeview (GTK_TREE_VIEW (glade_xml_get_widget (plugin->gxml, "commands")), plugin);
+ /* Callbacks for the OK button sensitivity in the actions dialog */
+ g_signal_connect_after (glade_xml_get_widget (plugin->gxml, "action-name"), "changed",
+ G_CALLBACK (cb_set_action_dialog_button_ok), plugin);
+ g_signal_connect_after (glade_xml_get_widget (plugin->gxml, "regex"), "changed",
+ G_CALLBACK (cb_set_action_dialog_button_ok), plugin);
+ g_signal_connect_after (glade_xml_get_widget (plugin->gxml, "button-add-command"), "clicked",
+ G_CALLBACK (cb_set_action_dialog_button_ok), plugin);
+ g_signal_connect_after (glade_xml_get_widget (plugin->gxml, "button-delete-command"), "clicked",
+ G_CALLBACK (cb_set_action_dialog_button_ok), plugin);
+
/* Run the dialog */
xfce_panel_plugin_block_menu (panel_plugin);
gtk_dialog_run (GTK_DIALOG (dialog));
xfce_panel_plugin_unblock_menu (panel_plugin);
+ gtk_widget_destroy (action_dialog);
gtk_widget_destroy (dialog);
g_object_unref (group);
g_object_unref (plugin->gxml);
@@ -612,7 +630,7 @@
GtkWidget *dialog;
gint res;
- dialog = glade_xml_get_widget (plugin->gxml, "entry-dialog");
+ dialog = glade_xml_get_widget (plugin->gxml, "action-dialog");
entry_dialog_cleanup (GTK_DIALOG (dialog), plugin);
res = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -661,16 +679,13 @@
gchar *title;
gint res;
- dialog = glade_xml_get_widget (plugin->gxml, "entry-dialog");
+ dialog = glade_xml_get_widget (plugin->gxml, "action-dialog");
entry_dialog_cleanup (GTK_DIALOG (dialog), plugin);
actions_model = gtk_tree_view_get_model (treeview);
gtk_tree_model_get_iter (actions_model, &iter, path);
gtk_tree_model_get (actions_model, &iter, 0, &entry, -1);
- gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "action-name")), entry->action_name);
- gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "regex")), g_regex_get_pattern (entry->regex));
-
commands_model = gtk_tree_view_get_model (GTK_TREE_VIEW (glade_xml_get_widget (plugin->gxml, "commands")));
#if GLIB_CHECK_VERSION (2,16,0)
GHashTableIter hiter;
@@ -687,6 +702,9 @@
g_hash_table_foreach (entry->commands, (GHFunc)__foreach_command_fill_commands, commands_model);
#endif
+ gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "action-name")), entry->action_name);
+ gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "regex")), g_regex_get_pattern (entry->regex));
+
res = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_hide (dialog);
@@ -747,6 +765,8 @@
{
GtkTreeModel *model;
+ gtk_widget_set_sensitive (glade_xml_get_widget (plugin->gxml, "action-dialog-button-ok"), FALSE);
+
gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "action-name")), "");
gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "regex")), "");
@@ -815,7 +835,7 @@
command = glade_xml_get_widget (plugin->gxml, "command");
if (gtk_entry_get_text (GTK_ENTRY (command_name))[0] == '\0'
- && gtk_entry_get_text (GTK_ENTRY (command))[0] == '\0')
+ || gtk_entry_get_text (GTK_ENTRY (command))[0] == '\0')
return;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (glade_xml_get_widget (plugin->gxml, "commands")));
@@ -844,8 +864,14 @@
GtkWidget *command;
gchar *title;
+ command_name = glade_xml_get_widget (plugin->gxml, "command-name");
+ command = glade_xml_get_widget (plugin->gxml, "command");
+
+ if (gtk_entry_get_text (GTK_ENTRY (command_name))[0] == '\0'
+ || gtk_entry_get_text (GTK_ENTRY (command))[0] == '\0')
+ return;
+
treeview = glade_xml_get_widget (plugin->gxml, "commands");
-
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
{
@@ -853,14 +879,12 @@
return;
}
- command_name = glade_xml_get_widget (plugin->gxml, "command-name");
- command = glade_xml_get_widget (plugin->gxml, "command");
title = g_strdup_printf ("<b>%s</b>\n<small>%s</small>",
gtk_entry_get_text (GTK_ENTRY (command_name)),
gtk_entry_get_text (GTK_ENTRY (command)));
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, title,
1, gtk_entry_get_text (GTK_ENTRY (command_name)),
- 2, gtk_entry_get_text (GTK_ENTRY (command)));
+ 2, gtk_entry_get_text (GTK_ENTRY (command)), -1);
g_free (title);
gtk_tree_selection_unselect_all (selection);
@@ -887,3 +911,33 @@
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
}
+static void
+cb_set_action_dialog_button_ok (GtkWidget *widget,
+ MyPlugin *plugin)
+{
+ const gchar *action_name;
+ const gchar *regex_pattern;
+ GRegex *regex;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean has_commands;
+ gboolean sensitive = FALSE;
+
+ action_name = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "action-name")));
+ regex_pattern = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (plugin->gxml, "regex")));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (glade_xml_get_widget (plugin->gxml, "commands")));
+ has_commands = gtk_tree_model_get_iter_first (model, &iter);
+
+ if (action_name[0] != '\0' && regex_pattern[0] != '\0' && has_commands)
+ {
+ if (regex = g_regex_new (regex_pattern, 0, 0, NULL))
+ {
+ sensitive = TRUE;
+ g_regex_unref (regex);
+ }
+ }
+
+ gtk_widget_set_sensitive (glade_xml_get_widget (plugin->gxml, "action-dialog-button-ok"), sensitive);
+ return;
+}
+
Modified: xfce4-clipman-plugin/trunk/panel-plugin/settings-dialog.glade
===================================================================
--- xfce4-clipman-plugin/trunk/panel-plugin/settings-dialog.glade 2009-03-31 20:57:54 UTC (rev 7068)
+++ xfce4-clipman-plugin/trunk/panel-plugin/settings-dialog.glade 2009-03-31 21:10:29 UTC (rev 7069)
@@ -340,7 +340,7 @@
</widget>
</child>
</widget>
- <widget class="GtkDialog" id="entry-dialog">
+ <widget class="GtkDialog" id="action-dialog">
<property name="title" translatable="yes">Edit Action</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
@@ -716,7 +716,7 @@
</packing>
</child>
<child>
- <widget class="GtkButton" id="entry-dialogbutton-ok1">
+ <widget class="GtkButton" id="action-dialog-button-ok">
<property name="label">gtk-ok</property>
<property name="response_id">1</property>
<property name="visible">True</property>
More information about the Goodies-commits
mailing list