forked from AuroraMiddleware/gtk
Bug 85292 – add an icon to gtkentry
2008-12-19 Cody Russell <bratsche@gnome.org> Bug 85292 – add an icon to gtkentry * gtk/gtkmarshalers.list: Add VOID:INT,BOXED * tests/testentryicons.c: Initial icon entry test * tests/Makefile.am: Add testentryicons * gtk/gtkentry.[ch]: Add API for setting primary/secondary icons and other features related to them. svn path=/trunk/; revision=21914
This commit is contained in:
parent
8ff5d4ffc4
commit
d6ca973cab
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2008-12-19 Cody Russell <bratsche@gnome.org>
|
||||
|
||||
Bug 85292 – add an icon to gtkentry
|
||||
|
||||
* gtk/gtkmarshalers.list: Add VOID:INT,BOXED
|
||||
* tests/testentryicons.c: Initial icon entry test
|
||||
* tests/Makefile.am: Add testentryicons
|
||||
* gtk/gtkentry.[ch]: Add API for setting primary/secondary icons
|
||||
and other features related to them.
|
||||
|
||||
2008-12-19 Marek Kasik <mkasik@redhat.com>
|
||||
|
||||
Bug 339318 - Allow page rendering to (optionally) happen in a thread
|
||||
|
2345
gtk/gtkentry.c
2345
gtk/gtkentry.c
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,10 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* Copyright (C) 2004-2006 Christian Hammond
|
||||
* Copyright (C) 2008 Cody Russell
|
||||
* Copyright (C) 2008 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
@ -36,6 +40,8 @@
|
||||
#include <gtk/gtkimcontext.h>
|
||||
#include <gtk/gtkmenu.h>
|
||||
#include <gtk/gtkentrycompletion.h>
|
||||
#include <gtk/gtkimage.h>
|
||||
#include <gtk/gtkselection.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -47,6 +53,11 @@ G_BEGIN_DECLS
|
||||
#define GTK_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY))
|
||||
#define GTK_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY, GtkEntryClass))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
GTK_ENTRY_ICON_SECONDARY
|
||||
} GtkEntryIconPosition;
|
||||
|
||||
typedef struct _GtkEntry GtkEntry;
|
||||
typedef struct _GtkEntryClass GtkEntryClass;
|
||||
@ -123,21 +134,21 @@ struct _GtkEntryClass
|
||||
|
||||
/* Action signals
|
||||
*/
|
||||
void (* activate) (GtkEntry *entry);
|
||||
void (* move_cursor) (GtkEntry *entry,
|
||||
GtkMovementStep step,
|
||||
gint count,
|
||||
gboolean extend_selection);
|
||||
void (* insert_at_cursor) (GtkEntry *entry,
|
||||
const gchar *str);
|
||||
void (* delete_from_cursor) (GtkEntry *entry,
|
||||
GtkDeleteType type,
|
||||
gint count);
|
||||
void (* backspace) (GtkEntry *entry);
|
||||
void (* cut_clipboard) (GtkEntry *entry);
|
||||
void (* copy_clipboard) (GtkEntry *entry);
|
||||
void (* paste_clipboard) (GtkEntry *entry);
|
||||
void (* toggle_overwrite) (GtkEntry *entry);
|
||||
void (* activate) (GtkEntry *entry);
|
||||
void (* move_cursor) (GtkEntry *entry,
|
||||
GtkMovementStep step,
|
||||
gint count,
|
||||
gboolean extend_selection);
|
||||
void (* insert_at_cursor) (GtkEntry *entry,
|
||||
const gchar *str);
|
||||
void (* delete_from_cursor) (GtkEntry *entry,
|
||||
GtkDeleteType type,
|
||||
gint count);
|
||||
void (* backspace) (GtkEntry *entry);
|
||||
void (* cut_clipboard) (GtkEntry *entry);
|
||||
void (* copy_clipboard) (GtkEntry *entry);
|
||||
void (* paste_clipboard) (GtkEntry *entry);
|
||||
void (* toggle_overwrite) (GtkEntry *entry);
|
||||
|
||||
/* hook to add other objects beside the entry (like in GtkSpinButton) */
|
||||
void (* get_text_area_size) (GtkEntry *entry,
|
||||
@ -147,8 +158,8 @@ struct _GtkEntryClass
|
||||
gint *height);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
};
|
||||
|
||||
GType gtk_entry_get_type (void) G_GNUC_CONST;
|
||||
@ -224,6 +235,56 @@ gdouble gtk_entry_get_progress_pulse_step (GtkEntry *entry);
|
||||
|
||||
void gtk_entry_progress_pulse (GtkEntry *entry);
|
||||
|
||||
/* Setting and managing icons
|
||||
*/
|
||||
void gtk_entry_set_icon_from_pixbuf (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
GdkPixbuf *pixbuf);
|
||||
void gtk_entry_set_icon_from_stock (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
const gchar *stock_id);
|
||||
void gtk_entry_set_icon_from_icon_name (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
const gchar *icon_name);
|
||||
void gtk_entry_set_icon_from_gicon (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
GIcon *icon);
|
||||
GtkImageType gtk_entry_get_storage_type (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos);
|
||||
GdkPixbuf* gtk_entry_get_pixbuf (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos);
|
||||
const gchar* gtk_entry_get_stock (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos);
|
||||
const gchar* gtk_entry_get_icon_name (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos);
|
||||
GIcon* gtk_entry_get_gicon (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos);
|
||||
void gtk_entry_set_icon_activatable (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
gboolean activatable);
|
||||
gboolean gtk_entry_get_icon_activatable (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos);
|
||||
void gtk_entry_set_icon_sensitive (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
gboolean sensitive);
|
||||
gboolean gtk_entry_get_icon_sensitive (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos);
|
||||
gint gtk_entry_get_icon_at_pos (GtkEntry *entry,
|
||||
gint x,
|
||||
gint y);
|
||||
void gtk_entry_set_icon_tooltip_text (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
const gchar *tooltip);
|
||||
void gtk_entry_set_icon_tooltip_markup (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
const gchar *tooltip);
|
||||
void gtk_entry_set_icon_drag_source (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
GtkTargetList *target_list,
|
||||
GdkDragAction actions);
|
||||
gint gtk_entry_get_current_icon_drag_source (GtkEntry *entry);
|
||||
|
||||
|
||||
/* Deprecated compatibility functions
|
||||
*/
|
||||
|
||||
|
@ -69,6 +69,7 @@ VOID:ENUM,FLOAT,BOOLEAN
|
||||
VOID:ENUM,INT
|
||||
VOID:ENUM,INT,BOOLEAN
|
||||
VOID:INT
|
||||
VOID:INT,BOXED
|
||||
VOID:INT,BOOLEAN
|
||||
VOID:INT,INT
|
||||
VOID:INT,INT,BOXED
|
||||
|
@ -39,6 +39,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
||||
testdnd \
|
||||
testellipsise \
|
||||
testentrycompletion \
|
||||
testentryicons \
|
||||
testfilechooser \
|
||||
testfilechooserbutton \
|
||||
testframe \
|
||||
@ -118,6 +119,7 @@ testclientmessage_DEPENDENCIES = $(TEST_DEPS)
|
||||
testdnd_DEPENDENCIES = $(TEST_DEPS)
|
||||
testellipsise_DEPENDENCIES = $(TEST_DEPS)
|
||||
testentrycompletion_DEPENDENCIES = $(TEST_DEPS)
|
||||
testentryicons_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfilechooser_DEPENDENCIES = $(TEST_DEPS)
|
||||
testfilechooserbutton_DEPENDENCIES = $(TEST_DEPS)
|
||||
testgtk_DEPENDENCIES = $(TEST_DEPS)
|
||||
@ -172,6 +174,7 @@ testclientmessage_LDADD = $(LDADDS)
|
||||
testdnd_LDADD = $(LDADDS)
|
||||
testellipsise_LDADD = $(LDADDS)
|
||||
testentrycompletion_LDADD = $(LDADDS)
|
||||
testentryicons_LDADD = $(LDADDS)
|
||||
testfilechooser_LDADD = $(LDADDS)
|
||||
testfilechooserbutton_LDADD = $(LDADDS)
|
||||
testgtk_LDADD = $(LDADDS)
|
||||
@ -225,6 +228,9 @@ testentrycompletion_SOURCES = \
|
||||
prop-editor.c \
|
||||
testentrycompletion.c
|
||||
|
||||
testentryicons_SOURCES = \
|
||||
testentryicons.c
|
||||
|
||||
testfilechooser_SOURCES = \
|
||||
prop-editor.c \
|
||||
testfilechooser.c
|
||||
|
124
tests/testentryicons.c
Normal file
124
tests/testentryicons.c
Normal file
@ -0,0 +1,124 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GIcon *icon;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Gtk Entry Icons Test");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 12);
|
||||
|
||||
g_signal_connect (G_OBJECT (window), "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
table = gtk_table_new (2, 4, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
||||
|
||||
/*
|
||||
* Open File - Sets the icon using a GIcon
|
||||
*/
|
||||
label = gtk_label_new ("Open File:");
|
||||
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
|
||||
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||
|
||||
icon = g_themed_icon_new_with_default_fallbacks ("folder");
|
||||
gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
icon);
|
||||
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
FALSE);
|
||||
|
||||
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
"Open a file");
|
||||
|
||||
/*
|
||||
* Save File - sets the icon using a stock id.
|
||||
*/
|
||||
label = gtk_label_new ("Save File:");
|
||||
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
|
||||
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), "Right-to-left");
|
||||
gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL);
|
||||
|
||||
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
GTK_STOCK_SAVE);
|
||||
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
"Save a file");
|
||||
|
||||
/*
|
||||
* Search - Uses a helper function
|
||||
*/
|
||||
label = gtk_label_new ("Search:");
|
||||
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
|
||||
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||
|
||||
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
GTK_STOCK_FIND);
|
||||
|
||||
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_SECONDARY,
|
||||
GTK_STOCK_CLEAR);
|
||||
|
||||
/*
|
||||
* Password - Sets the icon using a stock id
|
||||
*/
|
||||
label = gtk_label_new ("Password:");
|
||||
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 3, 4,
|
||||
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
|
||||
|
||||
gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
GTK_STOCK_DIALOG_AUTHENTICATION);
|
||||
|
||||
/* Name - Does not set any icons. */
|
||||
label = gtk_label_new ("Name:");
|
||||
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
|
||||
GTK_FILL, GTK_FILL, 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 4, 5,
|
||||
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user