vinagre r682 - in trunk: . data src
- From: jwendell svn gnome org
- To: svn-commits-list gnome org
- Subject: vinagre r682 - in trunk: . data src
- Date: Fri, 20 Mar 2009 20:31:28 +0000 (UTC)
Author: jwendell
Date: Fri Mar 20 20:31:28 2009
New Revision: 682
URL: http://svn.gnome.org/viewvc/vinagre?rev=682&view=rev
Log:
2009-03-20 Jonh Wendell <jwendell gnome org>
* src/vinagre-bookmarks.[ch],
* src/vinagre-bookmarks-ui.c,
* data/vinagre.glade: Don't allow items name duplicated on bookmarks.
Closes #574134.
Modified:
trunk/ChangeLog
trunk/data/vinagre.glade
trunk/src/vinagre-bookmarks-ui.c
trunk/src/vinagre-bookmarks.c
trunk/src/vinagre-bookmarks.h
Modified: trunk/data/vinagre.glade
==============================================================================
--- trunk/data/vinagre.glade (original)
+++ trunk/data/vinagre.glade Fri Mar 20 20:31:28 2009
@@ -742,7 +742,7 @@
</packing>
</child>
<child>
- <widget class="GtkButton" id="button8">
+ <widget class="GtkButton" id="save_button">
<property name="label">gtk-save</property>
<property name="response_id">-5</property>
<property name="visible">True</property>
@@ -1035,7 +1035,7 @@
</packing>
</child>
<child>
- <widget class="GtkButton" id="button6">
+ <widget class="GtkButton" id="save_button">
<property name="label">gtk-save</property>
<property name="response_id">-5</property>
<property name="visible">True</property>
Modified: trunk/src/vinagre-bookmarks-ui.c
==============================================================================
--- trunk/src/vinagre-bookmarks-ui.c (original)
+++ trunk/src/vinagre-bookmarks-ui.c Fri Mar 20 20:31:28 2009
@@ -27,13 +27,20 @@
#include "vinagre-bookmarks-tree.h"
static void
+control_save_button_visibility (GtkEntry *ed, GtkWidget *bt)
+{
+ gtk_widget_set_sensitive (bt,
+ gtk_entry_get_text_length (ed) > 0);
+}
+
+static void
show_dialog_folder (VinagreBookmarks *book,
GtkWindow *window,
VinagreBookmarksEntry *entry,
gboolean is_add)
{
GladeXML *xml;
- GtkWidget *dialog, *box, *tree, *name_entry;
+ GtkWidget *dialog, *box, *tree, *name_entry, *save_button;
const gchar *name;
xml = glade_xml_new (vinagre_utils_get_glade_filename (),
@@ -42,10 +49,12 @@
dialog = glade_xml_get_widget (xml, "bookmarks_add_edit_folder_dialog");
name_entry = glade_xml_get_widget (xml, "edit_bookmark_folder_name_entry");
box = glade_xml_get_widget (xml, "folder_box1");
+ save_button= glade_xml_get_widget (xml, "save_button");
gtk_window_set_transient_for (GTK_WINDOW (dialog), window);
gtk_entry_set_text (GTK_ENTRY (name_entry), vinagre_bookmarks_entry_get_name (entry));
gtk_editable_set_position (GTK_EDITABLE (name_entry), -1);
+ g_signal_connect (name_entry, "changed", G_CALLBACK (control_save_button_visibility), save_button);
tree = vinagre_bookmarks_tree_new ();
vinagre_bookmarks_tree_select_entry (VINAGRE_BOOKMARKS_TREE (tree),
@@ -53,20 +62,40 @@
gtk_box_pack_end (GTK_BOX (box), tree, TRUE, TRUE, 0);
gtk_widget_show_all (dialog);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
+ while (TRUE)
{
- if (is_add)
- g_object_unref (entry);
- goto finalize;
- }
+ VinagreBookmarksEntry *existing_entry;
- name = gtk_entry_get_text (GTK_ENTRY (name_entry));
- if (strlen (name) < 1)
- {
- vinagre_utils_show_error (NULL, _("Invalid name for this folder"), window);
- if (is_add)
- g_object_unref (entry);
- goto finalize;
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
+ {
+ if (is_add)
+ g_object_unref (entry);
+ goto finalize;
+ }
+
+ name = gtk_entry_get_text (GTK_ENTRY (name_entry));
+ if (strlen (name) < 1)
+ {
+ vinagre_utils_show_error (NULL, _("Invalid name for this folder"), GTK_WINDOW (dialog));
+ gtk_widget_grab_focus (name_entry);
+ continue;
+ }
+
+ existing_entry = vinagre_bookmarks_name_exists (book,
+ vinagre_bookmarks_tree_get_selected_entry (VINAGRE_BOOKMARKS_TREE (tree)),
+ name);
+ if (existing_entry && existing_entry != entry)
+ {
+ gchar *str = g_strdup_printf (_("The name \"%s\" is already used in this folder. Please use a different name."), name);
+ vinagre_utils_show_error (_("Invalid name for this item"),
+ str,
+ GTK_WINDOW (dialog));
+ g_free (str);
+ gtk_widget_grab_focus (name_entry);
+ continue;
+ }
+
+ break;
}
vinagre_bookmarks_entry_set_name (entry, name);
@@ -95,7 +124,7 @@
GladeXML *xml;
GtkWidget *dialog, *host_entry, *name_entry;
GtkWidget *fs_check, *sc_check, *vo_check;
- GtkWidget *box, *tree;
+ GtkWidget *box, *tree, *save_button;
VinagreConnection *conn;
const gchar *name;
@@ -109,6 +138,7 @@
sc_check = glade_xml_get_widget (xml, "edit_scaling_check");
vo_check = glade_xml_get_widget (xml, "edit_viewonly_check");
box = glade_xml_get_widget (xml, "folder_box");
+ save_button= glade_xml_get_widget (xml, "save_button");
gtk_window_set_transient_for (GTK_WINDOW (dialog), window);
conn = vinagre_bookmarks_entry_get_conn (entry);
@@ -129,25 +159,59 @@
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vo_check),
vinagre_connection_get_view_only (conn));
+ g_signal_connect (name_entry, "changed", G_CALLBACK (control_save_button_visibility), save_button);
+
tree = vinagre_bookmarks_tree_new ();
vinagre_bookmarks_tree_select_entry (VINAGRE_BOOKMARKS_TREE (tree),
vinagre_bookmarks_entry_get_parent (entry));
gtk_box_pack_end (GTK_BOX (box), tree, TRUE, TRUE, 0);
gtk_widget_show_all (dialog);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
- goto finalize;
- if (!vinagre_connection_split_string (gtk_entry_get_text (GTK_ENTRY (host_entry)),
- &host,
- &port,
- &error_str))
+ while (TRUE)
{
- vinagre_utils_show_error (NULL, error_str, window);
- g_free (error_str);
- goto finalize;
+ VinagreBookmarksEntry *existing_entry;
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
+ goto finalize;
+
+ name = gtk_entry_get_text (GTK_ENTRY (name_entry));
+ if (strlen (name) < 1)
+ {
+ vinagre_utils_show_error (NULL, _("Invalid name for this item"), GTK_WINDOW (dialog));
+ gtk_widget_grab_focus (name_entry);
+ continue;
+ }
+
+ existing_entry = vinagre_bookmarks_name_exists (book,
+ vinagre_bookmarks_tree_get_selected_entry (VINAGRE_BOOKMARKS_TREE (tree)),
+ name);
+ if (existing_entry && existing_entry != entry)
+ {
+ gchar *str = g_strdup_printf (_("The name \"%s\" is already used in this folder. Please use a different name."), name);
+ vinagre_utils_show_error (_("Invalid name for this item"),
+ str,
+ GTK_WINDOW (dialog));
+ g_free (str);
+ gtk_widget_grab_focus (name_entry);
+ continue;
+ }
+
+ if (!vinagre_connection_split_string (gtk_entry_get_text (GTK_ENTRY (host_entry)),
+ &host,
+ &port,
+ &error_str))
+ {
+ vinagre_utils_show_error (NULL, error_str, GTK_WINDOW (dialog));
+ g_free (error_str);
+ gtk_widget_grab_focus (host_entry);
+ continue;
+ }
+
+ break;
}
+ vinagre_connection_set_name (conn, name);
vinagre_connection_set_host (conn, host);
vinagre_connection_set_port (conn, port);
vinagre_connection_set_view_only (conn,
@@ -157,14 +221,6 @@
vinagre_connection_set_fullscreen (conn,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fs_check)));
- name = gtk_entry_get_text (GTK_ENTRY (name_entry));
- if (strlen (name) < 1)
- if (strlen (vinagre_connection_get_name (conn)) < 1)
- name = vinagre_connection_get_host (conn);
- else
- name = vinagre_connection_get_name (conn);
- vinagre_connection_set_name (conn, name);
-
if (!is_add)
{
g_object_ref (entry);
Modified: trunk/src/vinagre-bookmarks.c
==============================================================================
--- trunk/src/vinagre-bookmarks.c (original)
+++ trunk/src/vinagre-bookmarks.c Fri Mar 20 20:31:28 2009
@@ -519,4 +519,39 @@
return FALSE;
}
+
+VinagreBookmarksEntry *
+vinagre_bookmarks_name_exists (VinagreBookmarks *book,
+ VinagreBookmarksEntry *parent,
+ const gchar *name)
+{
+ GSList *entries, *l;
+
+ g_return_val_if_fail (VINAGRE_IS_BOOKMARKS (book), FALSE);
+
+ if (parent)
+ entries = vinagre_bookmarks_entry_get_children (parent);
+ else
+ entries = book->priv->entries;
+
+ for (l = entries; l; l = l->next)
+ {
+ VinagreBookmarksEntry *e = (VinagreBookmarksEntry *) l->data;
+
+ if (vinagre_bookmarks_entry_get_node (e) == VINAGRE_BOOKMARKS_ENTRY_NODE_FOLDER)
+ {
+ if (g_strcmp0 (vinagre_bookmarks_entry_get_name (e), name) == 0)
+ return e;
+ }
+ else
+ {
+ VinagreConnection *conn = vinagre_bookmarks_entry_get_conn (e);
+ if (g_strcmp0 (vinagre_connection_get_name (conn), name) == 0)
+ return e;
+ }
+ }
+
+ return NULL;
+}
+
/* vim: set ts=8: */
Modified: trunk/src/vinagre-bookmarks.h
==============================================================================
--- trunk/src/vinagre-bookmarks.h (original)
+++ trunk/src/vinagre-bookmarks.h Fri Mar 20 20:31:28 2009
@@ -70,9 +70,13 @@
gboolean vinagre_bookmarks_remove_entry (VinagreBookmarks *book,
VinagreBookmarksEntry *entry);
-VinagreConnection *vinagre_bookmarks_exists (VinagreBookmarks *book,
- const gchar *host,
- gint port);
+VinagreConnection *vinagre_bookmarks_exists (VinagreBookmarks *book,
+ const gchar *host,
+ gint port);
+
+VinagreBookmarksEntry *vinagre_bookmarks_name_exists (VinagreBookmarks *book,
+ VinagreBookmarksEntry *parent,
+ const gchar *name);
G_END_DECLS
#endif /* __VINAGRE_BOOKMARKS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]