changeset 7751:d691cb95ee67

[gaim-migrate @ 8396] Changes for the conversation "Find" dialog: -Makes the window manager "X" work correctly when closing the dialog -Added an "s" mnemonic for the search box -Hitting enter now performs the default action (Find) -The Find button grays and un-grays (aka sensitizes and desensitizes) itself based on the presence or absence of text in the search box. For this I moved a function from dialogs.c to util.[c|h]: gaim_gtk_set_sensitive_if_input() -HIGification suggestions from Steven Garrity: 1. Give the window a title ("Find") as is recommended by the HIG (http://developer.gnome.org/projects/gup/hig/1.0/windows.html#window-properties). 2. Drop the phrase "Enter a search phrase" altogether. Since the text box is already labeled (and if the window was labeled too), this phrase is redundant. Removing it simplifies the visual appearance of the window, and is one less thing to translate. 3.Change text box label from "Search term:" to "Search for:". This isn't a big deal, but the Search window in GEdit uses "Search for:" (I couldn't find much consistency anywhere else). 4.Move "Close" and "Find" buttons to be 12 pixels from the bottom and right edges of the window, as recommended by the HIG (http://developer.gnome.org/projects/gup/hig/1.0/layout.html#window-layout-spacing). Also thanks to Nathan Fredrickson for writing a patch for Steven's suggestions. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 04 Dec 2003 22:09:58 +0000
parents 14cc6614af93
children 68e205e746c9
files src/dialogs.c src/gtkconv.c src/gtkutils.c src/gtkutils.h
diffstat 4 files changed, 34 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Thu Dec 04 20:43:27 2003 +0000
+++ b/src/dialogs.c	Thu Dec 04 22:09:58 2003 +0000
@@ -629,12 +629,6 @@
 	info->gc = gaim_account_get_connection(account);
 }
 
-static void dialog_set_ok_sensitive(GtkWidget *entry, GtkWidget *dlg) {
-	const char *txt = gtk_entry_get_text(GTK_ENTRY(entry));
-	gtk_dialog_set_response_sensitive(GTK_DIALOG(dlg), GTK_RESPONSE_OK,
-			(*txt != '\0'));
-}
-
 void show_im_dialog()
 {
 	GtkWidget *hbox, *vbox;
@@ -692,7 +686,7 @@
 		gtk_entry_set_activates_default (GTK_ENTRY(info->entry), TRUE);
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry));
 		g_signal_connect(G_OBJECT(info->entry), "changed",
-				G_CALLBACK(dialog_set_ok_sensitive), imdialog);
+				G_CALLBACK(gaim_gtk_set_sensitive_if_input), imdialog);
 
 		if (gaim_connections_get_all()->next) {
 
@@ -770,7 +764,7 @@
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry));
 
 	g_signal_connect(G_OBJECT(info->entry), "changed",
-			G_CALLBACK(dialog_set_ok_sensitive), window);
+			G_CALLBACK(gaim_gtk_set_sensitive_if_input), window);
 
 	if (gaim_connections_get_all()->next) {
 
--- a/src/gtkconv.c	Thu Dec 04 20:43:27 2003 +0000
+++ b/src/gtkconv.c	Thu Dec 04 22:09:58 2003 +0000
@@ -738,6 +738,7 @@
 	case GTK_RESPONSE_OK:
 		gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), gtk_entry_get_text(GTK_ENTRY(s->entry)));
 		break;
+	case GTK_RESPONSE_DELETE_EVENT:
 	case GTK_RESPONSE_CLOSE:
 		gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml));
 		gtk_widget_destroy(s->gtkconv->dialogs.search);
@@ -748,13 +749,13 @@
 }
 
 static void
-menu_search_cb(gpointer data, guint action, GtkWidget *widget)
+menu_find_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	GaimConvWindow *win = (GaimConvWindow *)data;
 	GaimConversation *conv = gaim_conv_window_get_active_conversation(win);
 	GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win);
 	GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
-	GtkWidget *hbox, *vbox;
+	GtkWidget *hbox;
 	GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
 	GtkWidget *label, *entry;
 	struct _search *s;
@@ -762,34 +763,31 @@
 	if (gtkconv->dialogs.search)
 		return;
 
-	gtkconv->dialogs.search = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, GTK_WINDOW(gtkwin->window),
+	gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), GTK_WINDOW(gtkwin->window),
 							      GTK_DIALOG_DESTROY_WITH_PARENT,
 							      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
 							      GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL);
+	gtk_dialog_set_default_response (GTK_DIALOG(gtkconv->dialogs.search), GTK_RESPONSE_OK);
 	gtk_container_set_border_width (GTK_CONTAINER(gtkconv->dialogs.search), 6);
 	gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE);
 	gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE);
 	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 12);
 	gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 6);
 
-	hbox = gtk_hbox_new(FALSE, 6);
+	hbox = gtk_hbox_new(FALSE, 12);
 	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), hbox);
 	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
 	gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
-
-	vbox = gtk_vbox_new(FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(hbox), vbox);
+	gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), GTK_RESPONSE_OK, FALSE);
 
 	label = gtk_label_new(NULL);
-	gtk_label_set_markup(GTK_LABEL(label), _("<span weight='bold' size='larger'>Enter a search phrase\n</span>"));
-	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
-
-	hbox = gtk_hbox_new(FALSE, 6);
-	gtk_container_add(GTK_CONTAINER(vbox), hbox);
-	label = gtk_label_new(_("Search term: "));
+	gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:"));
 	entry = gtk_entry_new();
+	gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+	gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(entry));
+	g_signal_connect(G_OBJECT(entry), "changed", 
+					 G_CALLBACK(gaim_gtk_set_sensitive_if_input), 
+					 gtkconv->dialogs.search);
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
 
@@ -797,7 +795,6 @@
 	s->gtkconv = gtkconv;
 	s->entry = entry;
 
-	gtk_dialog_set_default_response (GTK_DIALOG(gtkconv->dialogs.search), GTK_RESPONSE_OK);
 	g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", G_CALLBACK(do_search_cb), s);
 
 	gtk_widget_show_all(gtkconv->dialogs.search);
@@ -2892,7 +2889,7 @@
 	{ N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0,
 	  "<StockItem>", GTK_STOCK_SAVE_AS },
 	{ N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL },
-	{ N_("/Conversation/Search..."), NULL, menu_search_cb, 0, "<StockItem>", GTK_STOCK_FIND },
+	{ N_("/Conversation/Find..."), NULL, menu_find_cb, 0, "<StockItem>", GTK_STOCK_FIND },
 
 	{ "/Conversation/sep1", NULL, NULL, 0, "<Separator>" },
 
--- a/src/gtkutils.c	Thu Dec 04 20:43:27 2003 +0000
+++ b/src/gtkutils.c	Thu Dec 04 22:09:58 2003 +0000
@@ -83,6 +83,14 @@
 	gtk_widget_set_sensitive(to_toggle, !sensitivity);
 }
 
+void
+gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog)
+{
+	const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
+	gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
+									  (*text != '\0'));
+}
+
 static void
 gaim_gtk_remove_tags(GaimGtkConversation *gtkconv, const char *tag)
 {
--- a/src/gtkutils.h	Thu Dec 04 20:43:27 2003 +0000
+++ b/src/gtkutils.h	Thu Dec 04 22:09:58 2003 +0000
@@ -129,6 +129,16 @@
 void gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle);
 
 /**
+ * Checks if text has been entered into a GtkTextEntry widget.  If 
+ * so, the GTK_RESPONSE_OK on the given dialog is set to TRUE.  
+ * Otherwise GTK_RESPONSE_OK is set to FALSE.
+ *
+ * @param entry  The text entry widget.
+ * @param dialog The dialog containing the text entry widget.
+ */
+void gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog);
+
+/**
  * Toggles the sensitivity of all widgets in a pointer array.
  *
  * @param w    @c NULL. Used for signal handlers.