Mercurial > pidgin
changeset 12833:cb2d493e1925
[gaim-migrate @ 15181]
Eliminate and empty (but not logically useless) if block by reworking the logic.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 11 Jan 2006 22:53:37 +0000 |
parents | 0c6a0362a48f |
children | 03ff00e0bb84 |
files | src/gtkimhtml.c |
diffstat | 1 files changed, 29 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkimhtml.c Wed Jan 11 22:52:48 2006 +0000 +++ b/src/gtkimhtml.c Wed Jan 11 22:53:37 2006 +0000 @@ -809,18 +809,42 @@ } - +static void fix_popup_menu_item_cb(GtkWidget *widget, gpointer data) +{ + gpointer *more_data = data; + int *count = more_data[0]; + GtkIMHtml *imhtml = more_data[1]; + + /* Destroy all items except Copy and Select All, if the text isn't editable. */ + if (!imhtml->editable && *count != 1 && *count != 5) + { + gtk_widget_destroy(widget); + } + else if (*count == 5 && gtk_text_buffer_get_char_count(imhtml->text_buffer) == 0) + { + /* There is no text in the buffer, so Select All should be insensitive. */ + gtk_widget_set_sensitive(widget, FALSE); + } + + (*count)++; +} static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) { + int count = 0; + gpointer more_data[2] = {&count, imhtml}; GtkWidget *menuitem; + gtk_container_foreach(GTK_CONTAINER(menu), fix_popup_menu_item_cb, more_data); + + if (!imhtml->editable) + return; + menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); gtk_widget_show(menuitem); gtk_widget_set_sensitive(menuitem, - (imhtml->editable && - gtk_clipboard_wait_is_text_available( - gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); + (gtk_clipboard_wait_is_text_available( + gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); /* put it after "Paste" */ gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3); @@ -1824,8 +1848,7 @@ if (sml == NULL) tree = imhtml->default_smilies; - else if ((tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { - } else { + else if (!(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { tree = gtk_smiley_tree_new(); g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree); }