Commit ac3dd907 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Fix interaction between icons and widget sensitivity. Also fix a few

2008-12-26  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkentry.c: Fix interaction between icons and widget sensitivity.
        Also fix a few typos.

        * tests/testentryicons.c: Add property editors.
        * tests/Makefile.am: Glue


svn path=/trunk/; revision=21941
parent b9ff8712
2008-12-26 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkentry.c: Fix interaction between icons and widget sensitivity.
Also fix a few typos.
* tests/testentryicons.c: Add property editors.
* tests/Makefile.am: Glue
2008-12-26 Matthias Clasen <mclasen@redhat.com> 2008-12-26 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkentry.c: Allow builtin icons when loading themed icons, * gtk/gtkentry.c: Allow builtin icons when loading themed icons,
......
...@@ -1045,7 +1045,7 @@ gtk_entry_class_init (GtkEntryClass *class) ...@@ -1045,7 +1045,7 @@ gtk_entry_class_init (GtkEntryClass *class)
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_SENSITIVE_PRIMARY, PROP_SENSITIVE_PRIMARY,
g_param_spec_boolean ("sensitive-primary", g_param_spec_boolean ("sensitive-primary",
P_("Primary icon sensitvitiy"), P_("Primary icon sensitive"),
P_("Whether the primary icon is sensitive"), P_("Whether the primary icon is sensitive"),
TRUE, TRUE,
GTK_PARAM_READWRITE)); GTK_PARAM_READWRITE));
...@@ -1063,7 +1063,7 @@ gtk_entry_class_init (GtkEntryClass *class) ...@@ -1063,7 +1063,7 @@ gtk_entry_class_init (GtkEntryClass *class)
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_SENSITIVE_SECONDARY, PROP_SENSITIVE_SECONDARY,
g_param_spec_boolean ("sensitive-secondary", g_param_spec_boolean ("sensitive-secondary",
P_("Secondary icon sensitivity"), P_("Secondary icon sensitive"),
P_("Whether the secondary icon is sensitive"), P_("Whether the secondary icon is sensitive"),
TRUE, TRUE,
GTK_PARAM_READWRITE)); GTK_PARAM_READWRITE));
...@@ -2124,8 +2124,9 @@ update_cursors (GtkWidget *widget) ...@@ -2124,8 +2124,9 @@ update_cursors (GtkWidget *widget)
if (icon_info->pixbuf != NULL) if (icon_info->pixbuf != NULL)
gdk_window_show (icon_info->window); gdk_window_show (icon_info->window);
if (icon_info->insensitive || if (GTK_WIDGET_IS_SENSITIVE (widget) &&
(icon_info->nonactivatable && icon_info->target_list == NULL)) (icon_info->insensitive ||
(icon_info->nonactivatable && icon_info->target_list == NULL)))
{ {
display = gtk_widget_get_display (widget); display = gtk_widget_get_display (widget);
cursor = gdk_cursor_new_for_display (display, GDK_XTERM); cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
...@@ -2756,7 +2757,8 @@ draw_icon (GtkWidget *widget, ...@@ -2756,7 +2757,8 @@ draw_icon (GtkWidget *widget,
x = (width - gdk_pixbuf_get_width (pixbuf)) / 2; x = (width - gdk_pixbuf_get_width (pixbuf)) / 2;
y = (height - gdk_pixbuf_get_height (pixbuf)) / 2; y = (height - gdk_pixbuf_get_height (pixbuf)) / 2;
if (icon_info->insensitive) if (!GTK_WIDGET_IS_SENSITIVE (widget) ||
icon_info->insensitive)
{ {
GdkPixbuf *temp_pixbuf; GdkPixbuf *temp_pixbuf;
...@@ -3720,6 +3722,8 @@ gtk_entry_state_changed (GtkWidget *widget, ...@@ -3720,6 +3722,8 @@ gtk_entry_state_changed (GtkWidget *widget,
gdk_cursor_unref (cursor); gdk_cursor_unref (cursor);
entry->mouse_cursor_obscured = FALSE; entry->mouse_cursor_obscured = FALSE;
update_cursors (widget);
} }
if (!GTK_WIDGET_IS_SENSITIVE (widget)) if (!GTK_WIDGET_IS_SENSITIVE (widget))
......
...@@ -229,6 +229,7 @@ testentrycompletion_SOURCES = \ ...@@ -229,6 +229,7 @@ testentrycompletion_SOURCES = \
testentrycompletion.c testentrycompletion.c
testentryicons_SOURCES = \ testentryicons_SOURCES = \
prop-editor.c \
testentryicons.c testentryicons.c
testfilechooser_SOURCES = \ testfilechooser_SOURCES = \
......
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <stdio.h> #include <stdio.h>
#include "prop-editor.h"
static void
clear_pressed (GtkEntry *entry, gint icon, GdkEvent *event, gpointer data)
{
if (icon == GTK_ENTRY_ICON_SECONDARY)
gtk_entry_set_text (entry, "");
}
static gboolean
delete_event_cb (GtkWidget *editor,
gint response,
gpointer user_data)
{
gtk_widget_hide (editor);
return TRUE;
}
static void
properties_cb (GtkWidget *button,
GObject *entry)
{
GtkWidget *editor;
editor = g_object_get_data (entry, "properties-dialog");
if (editor == NULL)
{
editor = create_prop_editor (G_OBJECT (entry), G_TYPE_INVALID);
gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
gtk_window_set_transient_for (GTK_WINDOW (editor),
GTK_WINDOW (gtk_widget_get_toplevel (button)));
g_signal_connect (editor, "delete-event", G_CALLBACK (delete_event_cb), NULL);
g_object_set_data (entry, "properties-dialog", editor);
}
gtk_window_present (GTK_WINDOW (editor));
}
int int
main (int argc, char **argv) main (int argc, char **argv)
...@@ -8,6 +48,7 @@ main (int argc, char **argv) ...@@ -8,6 +48,7 @@ main (int argc, char **argv)
GtkWidget *table; GtkWidget *table;
GtkWidget *label; GtkWidget *label;
GtkWidget *entry; GtkWidget *entry;
GtkWidget *button;
GIcon *icon; GIcon *icon;
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
...@@ -36,7 +77,9 @@ main (int argc, char **argv) ...@@ -36,7 +77,9 @@ main (int argc, char **argv)
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1, gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
icon = g_themed_icon_new_with_default_fallbacks ("folder"); icon = g_themed_icon_new ("folder");
g_themed_icon_append_name (G_THEMED_ICON (icon), "gtk-directory");
gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY, GTK_ENTRY_ICON_PRIMARY,
icon); icon);
...@@ -48,6 +91,13 @@ main (int argc, char **argv) ...@@ -48,6 +91,13 @@ main (int argc, char **argv)
GTK_ENTRY_ICON_PRIMARY, GTK_ENTRY_ICON_PRIMARY,
"Open a file"); "Open a file");
button = gtk_button_new_with_label ("Properties");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
/* /*
* Save File - sets the icon using a stock id. * Save File - sets the icon using a stock id.
*/ */
...@@ -61,7 +111,7 @@ main (int argc, char **argv) ...@@ -61,7 +111,7 @@ main (int argc, char **argv)
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
gtk_entry_set_text (GTK_ENTRY (entry), "‏Right-to-left"); gtk_entry_set_text (GTK_ENTRY (entry), "‏Right-to-left");
gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL); gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL);
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY, GTK_ENTRY_ICON_PRIMARY,
GTK_STOCK_SAVE); GTK_STOCK_SAVE);
...@@ -69,6 +119,12 @@ main (int argc, char **argv) ...@@ -69,6 +119,12 @@ main (int argc, char **argv)
GTK_ENTRY_ICON_PRIMARY, GTK_ENTRY_ICON_PRIMARY,
"Save a file"); "Save a file");
button = gtk_button_new_with_label ("Properties");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
/* /*
* Search - Uses a helper function * Search - Uses a helper function
*/ */
...@@ -88,6 +144,17 @@ main (int argc, char **argv) ...@@ -88,6 +144,17 @@ main (int argc, char **argv)
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY, GTK_ENTRY_ICON_SECONDARY,
GTK_STOCK_CLEAR); GTK_STOCK_CLEAR);
gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY,
FALSE);
g_signal_connect (entry, "icon-pressed", G_CALLBACK (clear_pressed), NULL);
button = gtk_button_new_with_label ("Properties");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
/* /*
* Password - Sets the icon using a stock id * Password - Sets the icon using a stock id
...@@ -106,6 +173,12 @@ main (int argc, char **argv) ...@@ -106,6 +173,12 @@ main (int argc, char **argv)
GTK_ENTRY_ICON_PRIMARY, GTK_ENTRY_ICON_PRIMARY,
GTK_STOCK_DIALOG_AUTHENTICATION); GTK_STOCK_DIALOG_AUTHENTICATION);
button = gtk_button_new_with_label ("Properties");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
GTK_FILL, GTK_FILL, 0, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
/* Name - Does not set any icons. */ /* Name - Does not set any icons. */
label = gtk_label_new ("Name:"); label = gtk_label_new ("Name:");
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5, gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
...@@ -116,6 +189,12 @@ main (int argc, char **argv) ...@@ -116,6 +189,12 @@ main (int argc, char **argv)
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 4, 5, gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 4, 5,
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
button = gtk_button_new_with_label ("Properties");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
GTK_FILL, GTK_FILL, 0, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (properties_cb), entry);
gtk_widget_show_all (window); gtk_widget_show_all (window);
gtk_main(); gtk_main();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment