[evolution-patches] e-url-entry patch
- From: Dan Winship <danw ximian com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] e-url-entry patch
- Date: Thu, 01 Apr 2004 11:54:54 -0500
I've had this lying in my tree for a while. It just makes the EUrlEntry
"go to url" button be insensitive when there's no URL.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/ChangeLog,v
retrieving revision 1.285
diff -u -r1.285 ChangeLog
--- ChangeLog 31 Mar 2004 10:06:01 -0000 1.285
+++ ChangeLog 1 Apr 2004 16:54:00 -0000
@@ -1,3 +1,12 @@
+2004-04-01 Dan Winship <danw ximian com>
+
+ * e-url-entry.c (init): Make the button initially insensitive.
+ Connect to the entry's "changed" signal.
+ (entry_changed_cb): sensitize the button iff the entry is
+ non-empty
+ (button_clicked_cb): simplify a bit by using gtk_entry_get_text
+ rather than gtk_editable_get_chars.
+
2004-03-31 Not Zed <NotZed Ximian com>
* e-filter-bar.c (menubar_activated): start the rule editor with
Index: e-url-entry.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-url-entry.c,v
retrieving revision 1.8
diff -u -r1.8 e-url-entry.c
--- e-url-entry.c 13 Jul 2003 19:29:03 -0000 1.8
+++ e-url-entry.c 1 Apr 2004 16:54:00 -0000
@@ -39,6 +39,7 @@
static void destroy (GtkObject *obj);
static void button_clicked_cb (GtkWidget *widget, gpointer data);
+static void entry_changed_cb (GtkEditable *editable, gpointer data);
static gboolean mnemonic_activate (GtkWidget *widget, gboolean group_cycling);
@@ -99,6 +100,7 @@
priv->entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (url_entry), priv->entry, TRUE, TRUE, 0);
priv->button = gtk_button_new ();
+ gtk_widget_set_sensitive (priv->button, FALSE);
gtk_box_pack_start (GTK_BOX (url_entry), priv->button, FALSE, FALSE, 0);
pixmap = gtk_image_new_from_file (MAP_DIR "/connect_to_url-16.xpm");
gtk_container_add (GTK_CONTAINER (priv->button), pixmap);
@@ -107,8 +109,10 @@
gtk_widget_show (priv->button);
gtk_widget_show (priv->entry);
- g_signal_connect((priv->button), "clicked",
- G_CALLBACK (button_clicked_cb), url_entry);
+ g_signal_connect (priv->button, "clicked",
+ G_CALLBACK (button_clicked_cb), url_entry);
+ g_signal_connect (priv->entry, "changed",
+ G_CALLBACK (entry_changed_cb), url_entry);
}
static void
@@ -165,12 +169,23 @@
{
EUrlEntry *url_entry;
EUrlEntryPrivate *priv;
- char *url;
+
+ url_entry = E_URL_ENTRY (data);
+ priv = url_entry->priv;
+
+ gnome_url_show (gtk_entry_get_text (GTK_ENTRY (priv->entry)), NULL);
+}
+
+static void
+entry_changed_cb (GtkEditable *editable, gpointer data)
+{
+ EUrlEntry *url_entry;
+ EUrlEntryPrivate *priv;
+ const char *url;
url_entry = E_URL_ENTRY (data);
priv = url_entry->priv;
- url = gtk_editable_get_chars (GTK_EDITABLE (priv->entry), 0, -1);
- gnome_url_show (url, NULL);
- g_free (url);
+ url = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ gtk_widget_set_sensitive (priv->button, url != NULL && *url != '\0');
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]