Use progress and icon GtkEntry features with GTK+ 2.16
This commit is contained in:
parent
a9ea07389a
commit
592e55c59b
7 changed files with 54 additions and 38 deletions
|
@ -864,7 +864,7 @@ static void cm_app_add_browser_cb(MidoriApp *app, MidoriBrowser *browser, Midori
|
||||||
GTK_ICON_ENTRY_SECONDARY, GTK_STOCK_CLEAR);
|
GTK_ICON_ENTRY_SECONDARY, GTK_STOCK_CLEAR);
|
||||||
gtk_icon_entry_set_icon_highlight(GTK_ICON_ENTRY (cmdata->filter_entry),
|
gtk_icon_entry_set_icon_highlight(GTK_ICON_ENTRY (cmdata->filter_entry),
|
||||||
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
||||||
g_signal_connect(cmdata->filter_entry, "icon_released",
|
g_signal_connect(cmdata->filter_entry, "icon-release",
|
||||||
G_CALLBACK(cm_filter_entry_clear_icon_released_cb), NULL);
|
G_CALLBACK(cm_filter_entry_clear_icon_released_cb), NULL);
|
||||||
g_signal_connect(cmdata->filter_entry, "changed", G_CALLBACK(cm_filter_entry_changed_cb), cmdata);
|
g_signal_connect(cmdata->filter_entry, "changed", G_CALLBACK(cm_filter_entry_changed_cb), cmdata);
|
||||||
g_signal_connect(cmdata->filter_entry, "activate", G_CALLBACK(cm_filter_entry_changed_cb), cmdata);
|
g_signal_connect(cmdata->filter_entry, "activate", G_CALLBACK(cm_filter_entry_changed_cb), cmdata);
|
||||||
|
|
|
@ -20,6 +20,24 @@
|
||||||
|
|
||||||
#include "gtkiconentry.h"
|
#include "gtkiconentry.h"
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION (2, 16, 0)
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_icon_entry_set_icon_from_pixbuf (GtkEntry* entry,
|
||||||
|
GtkEntryIconPosition position,
|
||||||
|
GdkPixbuf* pixbuf)
|
||||||
|
{
|
||||||
|
/* Without this ugly hack pixbuf icons don't work */
|
||||||
|
if (pixbuf)
|
||||||
|
{
|
||||||
|
gtk_widget_hide (GTK_WIDGET (entry));
|
||||||
|
gtk_entry_set_icon_from_pixbuf (entry, position, pixbuf);
|
||||||
|
gtk_widget_show (GTK_WIDGET (entry));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION (2, 14, 0)
|
#if GTK_CHECK_VERSION (2, 14, 0)
|
||||||
|
@ -61,9 +79,7 @@ typedef struct
|
||||||
GdkCursorType cursor_type;
|
GdkCursorType cursor_type;
|
||||||
gboolean custom_cursor;
|
gboolean custom_cursor;
|
||||||
GtkImageType storage_type;
|
GtkImageType storage_type;
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
GIcon *gicon;
|
GIcon *gicon;
|
||||||
#endif
|
|
||||||
gchar *icon_name;
|
gchar *icon_name;
|
||||||
gboolean insensitive;
|
gboolean insensitive;
|
||||||
} EntryIconInfo;
|
} EntryIconInfo;
|
||||||
|
@ -196,17 +212,17 @@ gtk_icon_entry_class_init (GtkIconEntryClass *klass)
|
||||||
G_TYPE_INT);
|
G_TYPE_INT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkIconEntry::icon-released:
|
* GtkIconEntry::icon-release:
|
||||||
* @entry: The entry on which the signal is emitted.
|
* @entry: The entry on which the signal is emitted.
|
||||||
* @icon_pos: The position of the clicked icon.
|
* @icon_pos: The position of the clicked icon.
|
||||||
* @button: The mouse button clicked.
|
* @button: The mouse button clicked.
|
||||||
*
|
*
|
||||||
* The ::icon-released signal is emitted on the button release from a
|
* The ::icon-release signal is emitted on the button release from a
|
||||||
* mouse click.
|
* mouse click.
|
||||||
*/
|
*/
|
||||||
if (!(signals[ICON_RELEASED] = g_signal_lookup ("icon-released", GTK_TYPE_ENTRY)))
|
if (!(signals[ICON_RELEASED] = g_signal_lookup ("icon-release", GTK_TYPE_ENTRY)))
|
||||||
signals[ICON_RELEASED] =
|
signals[ICON_RELEASED] =
|
||||||
g_signal_new ("icon-released",
|
g_signal_new ("icon-release",
|
||||||
G_TYPE_FROM_CLASS (gobject_class),
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||||
G_STRUCT_OFFSET (GtkIconEntryClass, icon_released),
|
G_STRUCT_OFFSET (GtkIconEntryClass, icon_released),
|
||||||
|
@ -274,7 +290,6 @@ gtk_icon_entry_class_init (GtkIconEntryClass *klass)
|
||||||
NULL,
|
NULL,
|
||||||
GTK_PARAM_WRITABLE));
|
GTK_PARAM_WRITABLE));
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_GICON_PRIMARY,
|
PROP_GICON_PRIMARY,
|
||||||
g_param_spec_object ("gicon-primary",
|
g_param_spec_object ("gicon-primary",
|
||||||
|
@ -290,7 +305,6 @@ gtk_icon_entry_class_init (GtkIconEntryClass *klass)
|
||||||
P_("GIcon for secondary icon"),
|
P_("GIcon for secondary icon"),
|
||||||
G_TYPE_ICON,
|
G_TYPE_ICON,
|
||||||
GTK_PARAM_READWRITE));
|
GTK_PARAM_READWRITE));
|
||||||
#endif
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GtkIconEntryPrivate));
|
g_type_class_add_private (klass, sizeof (GtkIconEntryPrivate));
|
||||||
}
|
}
|
||||||
|
@ -433,7 +447,6 @@ gtk_icon_entry_set_property (GObject *object,
|
||||||
g_value_get_string (value));
|
g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
case PROP_GICON_PRIMARY:
|
case PROP_GICON_PRIMARY:
|
||||||
gtk_icon_entry_set_icon_from_gicon (entry,
|
gtk_icon_entry_set_icon_from_gicon (entry,
|
||||||
GTK_ICON_ENTRY_PRIMARY,
|
GTK_ICON_ENTRY_PRIMARY,
|
||||||
|
@ -445,7 +458,6 @@ gtk_icon_entry_set_property (GObject *object,
|
||||||
GTK_ICON_ENTRY_SECONDARY,
|
GTK_ICON_ENTRY_SECONDARY,
|
||||||
g_value_get_object (value));
|
g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +483,6 @@ gtk_icon_entry_get_property (GObject *object,
|
||||||
GTK_ICON_ENTRY_SECONDARY));
|
GTK_ICON_ENTRY_SECONDARY));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
case PROP_GICON_PRIMARY:
|
case PROP_GICON_PRIMARY:
|
||||||
g_value_set_object (value,
|
g_value_set_object (value,
|
||||||
gtk_icon_entry_get_gicon (entry,
|
gtk_icon_entry_get_gicon (entry,
|
||||||
|
@ -482,7 +493,6 @@ gtk_icon_entry_get_property (GObject *object,
|
||||||
g_value_set_object (value,
|
g_value_set_object (value,
|
||||||
gtk_icon_entry_get_gicon (entry,
|
gtk_icon_entry_get_gicon (entry,
|
||||||
GTK_ICON_ENTRY_SECONDARY));
|
GTK_ICON_ENTRY_SECONDARY));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,8 +1348,6 @@ gtk_icon_entry_set_icon_from_icon_name (GtkIconEntry *entry,
|
||||||
* instead. If the current icon theme is changed, the icon will be updated
|
* instead. If the current icon theme is changed, the icon will be updated
|
||||||
* appropriately.
|
* appropriately.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
void
|
void
|
||||||
gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry,
|
gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry,
|
||||||
GtkIconEntryPosition icon_pos,
|
GtkIconEntryPosition icon_pos,
|
||||||
|
@ -1390,7 +1398,6 @@ gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry,
|
||||||
icon_pos,
|
icon_pos,
|
||||||
pixbuf);
|
pixbuf);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_icon_entry_set_cursor
|
* gtk_icon_entry_set_cursor
|
||||||
|
@ -1491,9 +1498,6 @@ gtk_icon_entry_get_pixbuf (const GtkIconEntry *entry,
|
||||||
*
|
*
|
||||||
* Returns: A #GIcon, or NULL if no icon is set or if the icon is not a GIcon.
|
* Returns: A #GIcon, or NULL if no icon is set or if the icon is not a GIcon.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
GIcon *
|
GIcon *
|
||||||
gtk_icon_entry_get_gicon (const GtkIconEntry *entry,
|
gtk_icon_entry_get_gicon (const GtkIconEntry *entry,
|
||||||
GtkIconEntryPosition icon_pos)
|
GtkIconEntryPosition icon_pos)
|
||||||
|
@ -1510,7 +1514,6 @@ gtk_icon_entry_get_gicon (const GtkIconEntry *entry,
|
||||||
|
|
||||||
return icon_info->storage_type == _GTK_IMAGE_GICON ? icon_info->gicon : NULL;
|
return icon_info->storage_type == _GTK_IMAGE_GICON ? icon_info->gicon : NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_icon_entry_get_icon_highlight
|
* gtk_icon_entry_get_icon_highlight
|
||||||
|
@ -1601,3 +1604,5 @@ gtk_icon_entry_set_icon_sensitive (const GtkIconEntry *icon_entry,
|
||||||
gdk_cursor_unref (cursor);
|
gdk_cursor_unref (cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -25,14 +25,27 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#endif
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION (2, 16, 0)
|
||||||
|
#define GtkIconEntry GtkEntry
|
||||||
|
#define GtkIconEntryPosition GtkEntryIconPosition
|
||||||
|
#define GTK_ICON_ENTRY_PRIMARY GTK_ENTRY_ICON_PRIMARY
|
||||||
|
#define GTK_ICON_ENTRY_SECONDARY GTK_ENTRY_ICON_SECONDARY
|
||||||
|
#define GTK_ICON_ENTRY GTK_ENTRY
|
||||||
|
#define GTK_TYPE_ICON_ENTRY GTK_TYPE_ENTRY
|
||||||
|
#define gtk_icon_entry_new gtk_entry_new
|
||||||
|
#define gtk_icon_entry_set_icon_from_stock gtk_entry_set_icon_from_stock
|
||||||
|
void
|
||||||
|
gtk_icon_entry_set_icon_from_pixbuf (GtkEntry* entry,
|
||||||
|
GtkEntryIconPosition position,
|
||||||
|
GdkPixbuf* pixbuf);
|
||||||
|
#define gtk_icon_entry_set_icon_highlight gtk_entry_set_icon_activatable
|
||||||
|
#else
|
||||||
|
|
||||||
#define GTK_TYPE_ICON_ENTRY (gtk_icon_entry_get_type())
|
#define GTK_TYPE_ICON_ENTRY (gtk_icon_entry_get_type())
|
||||||
#define GTK_ICON_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_ICON_ENTRY, GtkIconEntry))
|
#define GTK_ICON_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_ICON_ENTRY, GtkIconEntry))
|
||||||
#define GTK_ICON_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_ICON_ENTRY, GtkIconEntryClass))
|
#define GTK_ICON_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_ICON_ENTRY, GtkIconEntryClass))
|
||||||
|
@ -86,17 +99,15 @@ void gtk_icon_entry_set_icon_from_icon_name (GtkIconEntry *entry,
|
||||||
GtkIconEntryPosition icon_pos,
|
GtkIconEntryPosition icon_pos,
|
||||||
const gchar *icon_name);
|
const gchar *icon_name);
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
void gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry,
|
void gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry,
|
||||||
GtkIconEntryPosition icon_pos,
|
GtkIconEntryPosition icon_pos,
|
||||||
GIcon *icon);
|
GIcon *icon);
|
||||||
#endif
|
|
||||||
GdkPixbuf* gtk_icon_entry_get_pixbuf (const GtkIconEntry *entry,
|
GdkPixbuf* gtk_icon_entry_get_pixbuf (const GtkIconEntry *entry,
|
||||||
GtkIconEntryPosition icon_pos);
|
GtkIconEntryPosition icon_pos);
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
GIcon* gtk_icon_entry_get_gicon (const GtkIconEntry *entry,
|
GIcon* gtk_icon_entry_get_gicon (const GtkIconEntry *entry,
|
||||||
GtkIconEntryPosition icon_pos);
|
GtkIconEntryPosition icon_pos);
|
||||||
#endif
|
|
||||||
|
|
||||||
void gtk_icon_entry_set_icon_highlight (const GtkIconEntry *entry,
|
void gtk_icon_entry_set_icon_highlight (const GtkIconEntry *entry,
|
||||||
GtkIconEntryPosition icon_pos,
|
GtkIconEntryPosition icon_pos,
|
||||||
|
@ -117,6 +128,8 @@ void gtk_icon_entry_set_icon_sensitive (const GtkIconEntry *icon_entr
|
||||||
GtkIconEntryPosition icon_pos,
|
GtkIconEntryPosition icon_pos,
|
||||||
gboolean sensitive);
|
gboolean sensitive);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_ICON_ENTRY_H__ */
|
#endif /* __GTK_ICON_ENTRY_H__ */
|
||||||
|
|
|
@ -4257,7 +4257,7 @@ midori_browser_init (MidoriBrowser* browser)
|
||||||
GTK_STOCK_CLEAR);
|
GTK_STOCK_CLEAR);
|
||||||
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (browser->find_text),
|
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (browser->find_text),
|
||||||
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
||||||
g_signal_connect (browser->find_text, "icon_released",
|
g_signal_connect (browser->find_text, "icon-release",
|
||||||
G_CALLBACK (midori_browser_entry_clear_icon_released_cb), NULL);
|
G_CALLBACK (midori_browser_entry_clear_icon_released_cb), NULL);
|
||||||
g_signal_connect (browser->find_text, "activate",
|
g_signal_connect (browser->find_text, "activate",
|
||||||
G_CALLBACK (_action_find_next_activate), browser);
|
G_CALLBACK (_action_find_next_activate), browser);
|
||||||
|
|
|
@ -847,7 +847,7 @@ midori_location_action_connect_proxy (GtkAction* action,
|
||||||
midori_location_action_key_press_event_cb, action,
|
midori_location_action_key_press_event_cb, action,
|
||||||
"signal::focus-out-event",
|
"signal::focus-out-event",
|
||||||
midori_location_action_focus_out_event_cb, action,
|
midori_location_action_focus_out_event_cb, action,
|
||||||
"signal::icon-released",
|
"signal::icon-release",
|
||||||
midori_location_action_icon_released_cb, action,
|
midori_location_action_icon_released_cb, action,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,7 @@ midori_location_entry_class_init (MidoriLocationEntryClass* class)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HAVE_ENTRY_PROGRESS 1
|
#if !GTK_CHECK_VERSION (2, 16, 0)
|
||||||
|
|
||||||
#ifdef HAVE_ENTRY_PROGRESS
|
|
||||||
|
|
||||||
/* GTK+/ GtkEntry internal helper function
|
/* GTK+/ GtkEntry internal helper function
|
||||||
Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||||
|
@ -345,7 +343,7 @@ entry_expose_event (GtkWidget* entry,
|
||||||
|
|
||||||
gdk_drawable_get_size (text_area, &width, &height);
|
gdk_drawable_get_size (text_area, &width, &height);
|
||||||
|
|
||||||
if (location_entry->progress > 0.0/* && location_entry->progress < 1.0*/)
|
if (location_entry->progress > 0.0)
|
||||||
{
|
{
|
||||||
gtk_paint_box (entry->style, text_area,
|
gtk_paint_box (entry->style, text_area,
|
||||||
GTK_STATE_SELECTED, GTK_SHADOW_OUT,
|
GTK_STATE_SELECTED, GTK_SHADOW_OUT,
|
||||||
|
@ -362,18 +360,18 @@ void
|
||||||
midori_location_entry_set_progress (MidoriLocationEntry* location_entry,
|
midori_location_entry_set_progress (MidoriLocationEntry* location_entry,
|
||||||
gdouble progress)
|
gdouble progress)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ENTRY_PROGRESS
|
|
||||||
GtkWidget* child;
|
GtkWidget* child;
|
||||||
#endif
|
|
||||||
|
|
||||||
g_return_if_fail (MIDORI_IS_LOCATION_ENTRY (location_entry));
|
g_return_if_fail (MIDORI_IS_LOCATION_ENTRY (location_entry));
|
||||||
|
|
||||||
location_entry->progress = CLAMP (progress, 0.0, 1.0);
|
location_entry->progress = CLAMP (progress, 0.0, 1.0);
|
||||||
|
|
||||||
#ifdef HAVE_ENTRY_PROGRESS
|
|
||||||
child = gtk_bin_get_child (GTK_BIN (location_entry));
|
child = gtk_bin_get_child (GTK_BIN (location_entry));
|
||||||
|
#if !GTK_CHECK_VERSION (2, 16, 0)
|
||||||
if (GTK_ENTRY (child)->text_area)
|
if (GTK_ENTRY (child)->text_area)
|
||||||
gdk_window_invalidate_rect (GTK_ENTRY (child)->text_area, NULL, FALSE);
|
gdk_window_invalidate_rect (GTK_ENTRY (child)->text_area, NULL, FALSE);
|
||||||
|
#else
|
||||||
|
gtk_entry_set_progress_fraction (GTK_ENTRY (child), progress);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +395,7 @@ midori_location_entry_init (MidoriLocationEntry* location_entry)
|
||||||
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
GTK_ICON_ENTRY_SECONDARY, TRUE);
|
||||||
g_signal_connect_after (entry, "key-press-event",
|
g_signal_connect_after (entry, "key-press-event",
|
||||||
G_CALLBACK (entry_key_press_event), location_entry);
|
G_CALLBACK (entry_key_press_event), location_entry);
|
||||||
#ifdef HAVE_ENTRY_PROGRESS
|
#if !GTK_CHECK_VERSION (2, 16, 0)
|
||||||
g_signal_connect_after (entry, "expose-event",
|
g_signal_connect_after (entry, "expose-event",
|
||||||
G_CALLBACK (entry_expose_event), location_entry);
|
G_CALLBACK (entry_expose_event), location_entry);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -532,7 +532,7 @@ midori_search_action_connect_proxy (GtkAction* action,
|
||||||
midori_search_action_key_press_event_cb, action,
|
midori_search_action_key_press_event_cb, action,
|
||||||
"signal::focus-out-event",
|
"signal::focus-out-event",
|
||||||
midori_search_action_focus_out_event_cb, action,
|
midori_search_action_focus_out_event_cb, action,
|
||||||
"signal::icon-released",
|
"signal::icon-release",
|
||||||
midori_search_action_icon_released_cb, action,
|
midori_search_action_icon_released_cb, action,
|
||||||
"signal::scroll-event",
|
"signal::scroll-event",
|
||||||
midori_search_action_scroll_event_cb, action,
|
midori_search_action_scroll_event_cb, action,
|
||||||
|
|
Loading…
Reference in a new issue