From 2cf8d9323e9280b3c964ec9204e89e81bec8130c Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 20 Jul 2012 01:22:38 +0200 Subject: [PATCH] Require GTK+ 2.16 or later --- README | 4 +- extensions/addons.c | 10 - .../cookie-manager/cookie-manager-page.c | 5 - extensions/tab-panel.c | 4 - katze/gtk3-compat.c | 38 - katze/gtk3-compat.h | 35 - katze/katze-utils.c | 16 - midori/gtkiconentry.c | 1925 ----------------- midori/gtkiconentry.h | 94 - midori/midori-browser.c | 4 - midori/midori-locationaction.c | 17 - midori/midori-view.c | 4 - midori/sokoke.c | 9 - toolbars/midori-findbar.c | 5 - wscript | 2 +- 15 files changed, 3 insertions(+), 2169 deletions(-) diff --git a/README b/README index 88f8a396..cc78dc95 100644 --- a/README +++ b/README @@ -11,10 +11,10 @@ Midori is a lightweight web browser. * Straightforward bookmark management. * Customizable interface, extensions written in C and Vala. -Requirements: GLib 2.22, GTK+ 2.10, WebkitGTK+ 1.1.17, libXML2, +Requirements: GLib 2.22, GTK+ 2.16, WebkitGTK+ 1.1.17, libXML2, libsoup 2.27.90, sqlite 3.0, Vala 0.14 -Optional: GTK+ 3.0, Unique 0.9, libnotify +Optional: GTK+ 3.0, Unique 0.9, libnotify, gcr For installation instructions read INSTALL. diff --git a/extensions/addons.c b/extensions/addons.c index ad705a11..5cfce23d 100644 --- a/extensions/addons.c +++ b/extensions/addons.c @@ -336,23 +336,13 @@ addons_button_add_clicked_cb (GtkToolItem* toolitem, if (!g_file_test (path, G_FILE_TEST_EXISTS)) katze_mkdir_with_parents (path, 0700); - #if !GTK_CHECK_VERSION (2, 14, 0) - files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dialog)); - #else files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (dialog)); - #endif - while (files) { GFile* src_file; GError* error = NULL; - #if !GTK_CHECK_VERSION (2, 14, 0) - src_file = g_file_new_for_path (files); - #else src_file = files->data; - #endif - if (G_IS_FILE (src_file)) { GFile* dest_file; diff --git a/extensions/cookie-manager/cookie-manager-page.c b/extensions/cookie-manager/cookie-manager-page.c index d21d128d..422b3db1 100644 --- a/extensions/cookie-manager/cookie-manager-page.c +++ b/extensions/cookie-manager/cookie-manager-page.c @@ -702,7 +702,6 @@ static gchar *cm_get_domain_description_text(const gchar *domain, gint cookie_co } -#if GTK_CHECK_VERSION(2, 12, 0) static gboolean cm_tree_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, CookieManagerPage *cmp) { @@ -731,8 +730,6 @@ static gboolean cm_tree_query_tooltip(GtkWidget *widget, gint x, gint y, gboolea return FALSE; } -#endif - static gboolean cm_filter_match(const gchar *haystack, const gchar *needle) { @@ -1045,10 +1042,8 @@ static GtkWidget *cm_tree_prepare(CookieManagerPage *cmp) g_signal_connect(treeview, "popup-menu", G_CALLBACK(cm_tree_popup_menu_cb), cmp); /* tooltips */ -#if GTK_CHECK_VERSION(2, 12, 0) gtk_widget_set_has_tooltip(treeview, TRUE); g_signal_connect(treeview, "query-tooltip", G_CALLBACK(cm_tree_query_tooltip), cmp); -#endif /* drag'n'drop */ gtk_tree_view_enable_model_drag_source( diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c index 24600dfc..44e23e6a 100644 --- a/extensions/tab-panel.c +++ b/extensions/tab-panel.c @@ -143,7 +143,6 @@ midori_extension_cursor_or_row_changed_cb (GtkTreeView* treeview, /* Nothing to do */ } -#if GTK_CHECK_VERSION (2, 12, 0) static gboolean tab_panel_treeview_query_tooltip_cb (GtkWidget* treeview, gint x, @@ -171,7 +170,6 @@ tab_panel_treeview_query_tooltip_cb (GtkWidget* treeview, return TRUE; } -#endif static void midori_extension_row_activated_cb (GtkTreeView* treeview, @@ -534,11 +532,9 @@ tab_panel_app_add_browser_cb (MidoriApp* app, treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE); - #if GTK_CHECK_VERSION (2, 12, 0) g_signal_connect (treeview, "query-tooltip", G_CALLBACK (tab_panel_treeview_query_tooltip_cb), NULL); gtk_widget_set_has_tooltip (treeview, TRUE); - #endif column = gtk_tree_view_column_new (); renderer_pixbuf = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE); diff --git a/katze/gtk3-compat.c b/katze/gtk3-compat.c index 8be80914..9586aac8 100644 --- a/katze/gtk3-compat.c +++ b/katze/gtk3-compat.c @@ -110,41 +110,3 @@ gtk_entry_get_placeholder_text (GtkEntry* entry) } #endif -#if !GTK_CHECK_VERSION (2, 12, 0) - -void -gtk_widget_set_has_tooltip (GtkWidget* widget, - gboolean has_tooltip) -{ - /* Do nothing */ -} - -void -gtk_widget_set_tooltip_text (GtkWidget* widget, - const gchar* text) -{ - if (text && *text) - { - static GtkTooltips* tooltips = NULL; - if (G_UNLIKELY (!tooltips)) - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, widget, text, NULL); - } -} - -void -gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem, - const gchar* text) -{ - if (text && *text) - { - static GtkTooltips* tooltips = NULL; - if (G_UNLIKELY (!tooltips)) - tooltips = gtk_tooltips_new (); - - gtk_tool_item_set_tooltip (toolitem, tooltips, text, NULL); - } -} - -#endif - diff --git a/katze/gtk3-compat.h b/katze/gtk3-compat.h index 71a1ef19..12981b1a 100644 --- a/katze/gtk3-compat.h +++ b/katze/gtk3-compat.h @@ -39,25 +39,6 @@ G_BEGIN_DECLS #define g_format_size(sz) g_format_size_for_display ((goffset)sz) #endif -#if !GTK_CHECK_VERSION (2, 14, 0) - #define gtk_dialog_get_content_area(dlg) dlg->vbox - #define gtk_dialog_get_action_area(dlg) dlg->action_area - #define gtk_widget_get_window(wdgt) wdgt->window - #define gtk_adjustment_get_page_size(adj) adj->page_size - #define gtk_adjustment_get_upper(adj) adj->upper - #define gtk_adjustment_get_lower(adj) adj->lower - #define gtk_adjustment_get_value(adj) adj->value -#endif - -#if !GTK_CHECK_VERSION (2, 16, 0) - #define GTK_ACTIVATABLE GTK_WIDGET - #define gtk_activatable_get_related_action gtk_widget_get_action - #define gtk_menu_item_set_label(menuitem, label) \ - gtk_label_set_label (GTK_LABEL (GTK_BIN (menuitem)->child), \ - label ? label : ""); - #define gtk_image_menu_item_set_always_show_image(menuitem, yesno) () -#endif - #if !GTK_CHECK_VERSION (2, 18, 0) #define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL (widget) #define gtk_widget_has_focus(widget) GTK_WIDGET_HAS_FOCUS (widget) @@ -95,22 +76,6 @@ G_BEGIN_DECLS const gchar* gtk_entry_get_placeholder_text (GtkEntry* entry); #endif -#if !GTK_CHECK_VERSION(2, 12, 0) - -void -gtk_widget_set_has_tooltip (GtkWidget* widget, - gboolean has_tooltip); - -void -gtk_widget_set_tooltip_text (GtkWidget* widget, - const gchar* text); - -void -gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem, - const gchar* text); - -#endif - #if !GTK_CHECK_VERSION (2, 24 ,0) #define gtk_combo_box_text_append_text gtk_combo_box_append_text #define gtk_combo_box_text_new gtk_combo_box_new_text diff --git a/katze/katze-utils.c b/katze/katze-utils.c index 9b41d815..6842581b 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -277,7 +277,6 @@ proxy_combo_box_changed_cb (GtkComboBox* button, if (custom_value) { - #if GTK_CHECK_VERSION (2, 12, 0) if (value == custom_value) gtk_widget_set_tooltip_text (GTK_WIDGET (button), NULL); else @@ -286,7 +285,6 @@ proxy_combo_box_changed_cb (GtkComboBox* button, gtk_widget_set_tooltip_text (GTK_WIDGET (button), custom_text); g_free (custom_text); } - #endif } } #endif @@ -523,14 +521,8 @@ katze_property_proxy (gpointer object, string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value); gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (widget), string ? string : ""); - #if GTK_CHECK_VERSION (2, 12, 0) g_signal_connect (widget, "file-set", G_CALLBACK (proxy_uri_file_set_cb), object); - #else - if (pspec->flags & G_PARAM_WRITABLE) - g_signal_connect (widget, "selection-changed", - G_CALLBACK (proxy_uri_file_set_cb), object); - #endif } else if (type == G_TYPE_PARAM_STRING && (_hint == I_("font") || _hint == I_("font-monospace"))) @@ -819,10 +811,8 @@ katze_property_proxy (gpointer object, g_object_set_data_full (G_OBJECT (entry), "property", g_strdup (custom), g_free); } - #if GTK_CHECK_VERSION (2, 12, 0) else gtk_widget_set_tooltip_text (widget, custom_text); - #endif g_free (custom_text); @@ -837,10 +827,8 @@ katze_property_proxy (gpointer object, widget = gtk_label_new (gettext (nick)); g_free (string); - #if GTK_CHECK_VERSION (2, 12, 0) if (!gtk_widget_get_tooltip_text (widget)) gtk_widget_set_tooltip_text (widget, g_param_spec_get_blurb (pspec)); - #endif gtk_widget_set_sensitive (widget, pspec->flags & G_PARAM_WRITABLE); g_object_set_data_full (G_OBJECT (widget), "property", @@ -888,9 +876,7 @@ katze_property_label (gpointer object, nick = g_param_spec_get_nick (pspec); widget = gtk_label_new (nick); - #if GTK_CHECK_VERSION (2, 12, 0) gtk_widget_set_tooltip_text (widget, g_param_spec_get_blurb (pspec)); - #endif gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); return widget; @@ -1583,10 +1569,8 @@ katze_uri_entry_new (GtkWidget* other_widget) { GtkWidget* entry = gtk_entry_new (); - #if GTK_CHECK_VERSION (2, 16, 0) gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, g_themed_icon_new_with_default_fallbacks ("text-html-symbolic")); - #endif g_signal_connect (entry, "changed", G_CALLBACK (katze_uri_entry_changed_cb), other_widget); return entry; diff --git a/midori/gtkiconentry.c b/midori/gtkiconentry.c index 6e5b97ba..c15ac1f6 100644 --- a/midori/gtkiconentry.c +++ b/midori/gtkiconentry.c @@ -1,27 +1,5 @@ -/* - * Copyright (C) 2004-2006 Christian Hammond. - * Copyright (C) 2008 Cody Russell - * - * 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 - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - #include "gtkiconentry.h" -#if GTK_CHECK_VERSION (2, 16, 0) - void gtk_icon_entry_set_icon_from_pixbuf (GtkEntry* entry, GtkEntryIconPosition position, @@ -36,1906 +14,3 @@ gtk_icon_entry_set_icon_from_pixbuf (GtkEntry* entry, gtk_entry_set_icon_activatable (entry, position, activatable); } -#else - -#include - -#if GTK_CHECK_VERSION (2, 14, 0) -#define _GTK_IMAGE_GICON GTK_IMAGE_GICON -#else -#define _GTK_IMAGE_GICON 8 -#endif - -#ifndef GTK_PARAM_READABLE -#define GTK_PARAM_READABLE G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB -#endif - -#ifndef GTK_PARAM_WRITABLE -#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB -#endif - -#ifndef GTK_PARAM_READWRITE -#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB -#endif - -#define P_(s) (s) - -#define ICON_MARGIN 2 -#define MAX_ICONS 2 - -#define IS_VALID_ICON_ENTRY_POSITION(pos) \ - ((pos) == GTK_ICON_ENTRY_PRIMARY || \ - (pos) == GTK_ICON_ENTRY_SECONDARY) - -typedef struct -{ - GdkPixbuf *pixbuf; - gboolean highlight; - gboolean hovered; - GdkWindow *window; - gchar *tooltip_text; - GdkCursorType cursor_type; - gboolean custom_cursor; - GtkImageType storage_type; - GIcon *gicon; - gchar *icon_name; - gboolean insensitive; -} EntryIconInfo; - -struct _GtkIconEntryPrivate -{ - gdouble fraction; - EntryIconInfo icons[MAX_ICONS]; - - gulong icon_released_id; -}; - -enum -{ - ICON_PRESSED, - ICON_RELEASED, - LAST_SIGNAL -}; - -enum -{ - PROP_0, - PROP_PIXBUF_PRIMARY, - PROP_PIXBUF_SECONDARY, - PROP_STOCK_PRIMARY, - PROP_STOCK_SECONDARY, - PROP_ICON_NAME_PRIMARY, - PROP_ICON_NAME_SECONDARY, - PROP_GICON_PRIMARY, - PROP_GICON_SECONDARY, - PROP_SENSITIVITY_PRIMARY, - PROP_SENSITIVITY_SECONDARY -}; - -static void gtk_icon_entry_editable_init (GtkEditableClass *iface); -static void gtk_icon_entry_finalize (GObject *obj); -static void gtk_icon_entry_dispose (GObject *obj); -static void gtk_icon_entry_map (GtkWidget *widget); -static void gtk_icon_entry_unmap (GtkWidget *widget); -static void gtk_icon_entry_realize (GtkWidget *widget); -static void gtk_icon_entry_unrealize (GtkWidget *widget); -static void gtk_icon_entry_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_icon_entry_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gint gtk_icon_entry_expose (GtkWidget *widget, - GdkEventExpose *event); -static gint gtk_icon_entry_enter_notify (GtkWidget *widget, - GdkEventCrossing *event); -static gint gtk_icon_entry_leave_notify (GtkWidget *widget, - GdkEventCrossing *event); -static gint gtk_icon_entry_button_press (GtkWidget *widget, - GdkEventButton *event); -static gint gtk_icon_entry_button_release (GtkWidget *widget, - GdkEventButton *event); -static void gtk_icon_entry_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_icon_entry_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gtk_icon_entry_style_set (GtkWidget *widget, - GtkStyle *prev_style); -static void gtk_icon_entry_set_icon_internal (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - GdkPixbuf *pixbuf); -static void icon_theme_changed (GtkIconEntry *entry); - - -static GtkEntryClass *parent_class = NULL; -static guint signals[LAST_SIGNAL] = {0}; - -G_DEFINE_TYPE_EXTENDED (GtkIconEntry, gtk_icon_entry, GTK_TYPE_ENTRY, - 0, - G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, - gtk_icon_entry_editable_init)); - -static void -gtk_icon_entry_class_init (GtkIconEntryClass *klass) -{ - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkEntryClass *entry_class; - - parent_class = g_type_class_peek_parent(klass); - - gobject_class = G_OBJECT_CLASS(klass); - object_class = GTK_OBJECT_CLASS(klass); - widget_class = GTK_WIDGET_CLASS(klass); - entry_class = GTK_ENTRY_CLASS(klass); - - gobject_class->finalize = gtk_icon_entry_finalize; - gobject_class->dispose = gtk_icon_entry_dispose; - gobject_class->set_property = gtk_icon_entry_set_property; - gobject_class->get_property = gtk_icon_entry_get_property; - - widget_class->map = gtk_icon_entry_map; - widget_class->unmap = gtk_icon_entry_unmap; - widget_class->realize = gtk_icon_entry_realize; - widget_class->unrealize = gtk_icon_entry_unrealize; - widget_class->size_request = gtk_icon_entry_size_request; - widget_class->size_allocate = gtk_icon_entry_size_allocate; - widget_class->expose_event = gtk_icon_entry_expose; - widget_class->enter_notify_event = gtk_icon_entry_enter_notify; - widget_class->leave_notify_event = gtk_icon_entry_leave_notify; - widget_class->button_press_event = gtk_icon_entry_button_press; - widget_class->button_release_event = gtk_icon_entry_button_release; - widget_class->style_set = gtk_icon_entry_style_set; - - /** - * GtkIconEntry::icon-pressed: - * @entry: The entry on which the signal is emitted. - * @icon_pos: The position of the clicked icon. - * @button: The mouse button clicked. - * - * The ::icon-pressed signal is emitted when an icon is clicked. - */ - if (!(signals[ICON_PRESSED] = g_signal_lookup ("icon-pressed", GTK_TYPE_ENTRY))) - signals[ICON_PRESSED] = - g_signal_new ("icon-pressed", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkIconEntryClass, icon_pressed), - NULL, NULL, - gtk_marshal_VOID__INT_INT, - G_TYPE_NONE, 2, - G_TYPE_INT, - G_TYPE_INT); - - /** - * GtkIconEntry::icon-release: - * @entry: The entry on which the signal is emitted. - * @icon_pos: The position of the clicked icon. - * @button: The mouse button clicked. - * - * The ::icon-release signal is emitted on the button release from a - * mouse click. - */ - if (!(signals[ICON_RELEASED] = g_signal_lookup ("icon-release", GTK_TYPE_ENTRY))) - signals[ICON_RELEASED] = - g_signal_new ("icon-release", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkIconEntryClass, icon_released), - NULL, NULL, - gtk_marshal_VOID__INT_INT, - G_TYPE_NONE, 2, - G_TYPE_INT, - G_TYPE_INT); - - /** - * GtkIconEntry:pixbuf-primary: - * - * An image to use as the primary icon for the entry. - */ - g_object_class_install_property (gobject_class, - PROP_PIXBUF_PRIMARY, - g_param_spec_object ("pixbuf-primary", - P_("Primary pixbuf"), - P_("Primary pixbuf for the entry"), - GDK_TYPE_PIXBUF, - GTK_PARAM_READWRITE)); - - /** - * GtkIconEntry:pixbuf-secondary: - * - * An image to use as the secondary icon for the entry. - */ - g_object_class_install_property (gobject_class, - PROP_PIXBUF_SECONDARY, - g_param_spec_object ("pixbuf-secondary", - P_("Secondary pixbuf"), - P_("Secondary pixbuf for the entry"), - GDK_TYPE_PIXBUF, - GTK_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_STOCK_PRIMARY, - g_param_spec_string ("stock-primary", - P_("Primary stock ID"), - P_("Stock ID for primary icon"), - NULL, - GTK_PARAM_WRITABLE)); - - g_object_class_install_property (gobject_class, - PROP_STOCK_SECONDARY, - g_param_spec_string ("stock-secondary", - P_("Secondary stock ID"), - P_("Stock ID for secondary icon"), - NULL, - GTK_PARAM_WRITABLE)); - - g_object_class_install_property (gobject_class, - PROP_ICON_NAME_PRIMARY, - g_param_spec_string ("icon-name-primary", - P_("Primary icon name"), - P_("Icon name for primary icon"), - NULL, - GTK_PARAM_WRITABLE)); - - g_object_class_install_property (gobject_class, - PROP_ICON_NAME_SECONDARY, - g_param_spec_string ("icon-name-secondary", - P_("Secondary icon name"), - P_("Icon name for secondary icon"), - NULL, - GTK_PARAM_WRITABLE)); - - g_object_class_install_property (gobject_class, - PROP_GICON_PRIMARY, - g_param_spec_object ("gicon-primary", - P_("Primary GIcon"), - P_("GIcon for primary icon"), - G_TYPE_ICON, - GTK_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_GICON_SECONDARY, - g_param_spec_object ("gicon-secondary", - P_("Secondary GIcon"), - P_("GIcon for secondary icon"), - G_TYPE_ICON, - GTK_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (GtkIconEntryPrivate)); -} - -static void -gtk_icon_entry_editable_init (GtkEditableClass *iface) -{ -}; - -/* GTK+/ GtkEntry internal helper function - Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - Modified by the GTK+ Team and others 1997-2000 - Copied from Gtk+ 2.13, whitespace adjusted */ -static void -gtk_entry_get_pixel_ranges (GtkEntry *entry, - gint **ranges, - gint *n_ranges) -{ - gint start_char, end_char; - - if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), - &start_char, &end_char)) - { - PangoLayout *layout = gtk_entry_get_layout (entry); - PangoLayoutLine *line = pango_layout_get_lines (layout)->data; - const char *text = pango_layout_get_text (layout); - gsize start_index = g_utf8_offset_to_pointer (text, start_char) - text; - gsize end_index = g_utf8_offset_to_pointer (text, end_char) - text; - gint real_n_ranges, i; - - pango_layout_line_get_x_ranges (line, - start_index, end_index, ranges, &real_n_ranges); - - if (ranges) - { - gint *r = *ranges; - - for (i = 0; i < real_n_ranges; ++i) - { - r[2 * i + 1] = (r[2 * i + 1] - r[2 * i]) / PANGO_SCALE; - r[2 * i] = r[2 * i] / PANGO_SCALE; - } - } - - if (n_ranges) - *n_ranges = real_n_ranges; - } - else - { - if (n_ranges) - *n_ranges = 0; - if (ranges) - *ranges = NULL; - } -} - -/* GTK+/ GtkEntry internal helper function - Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - Modified by the GTK+ Team and others 1997-2000 - Copied from Gtk+ 2.13, whitespace adjusted - Code adjusted to not rely on internal qdata */ -static void -_gtk_entry_effective_inner_border (GtkEntry *entry, - GtkBorder *border) -{ - static const GtkBorder default_inner_border = { 2, 2, 2, 2 }; - GtkBorder *tmp_border; - - tmp_border = (GtkBorder*) gtk_entry_get_inner_border (entry); - - if (tmp_border) - { - *border = *tmp_border; - return; - } - - gtk_widget_style_get (GTK_WIDGET (entry), "inner-border", &tmp_border, NULL); - - if (tmp_border) - { - *border = *tmp_border; - gtk_border_free (tmp_border); - return; - } - - *border = default_inner_border; -} - -static void -gtk_entry_borders (GtkEntry* entry, - gint* xborder, - gint* yborder, - gboolean* interior_focus, - gint* focus_width) -{ - GtkWidget *widget = GTK_WIDGET (entry); - - if (entry->has_frame) - { - *xborder = widget->style->xthickness; - *yborder = widget->style->ythickness; - } - else - { - *xborder = 0; - *yborder = 0; - } - - gtk_widget_style_get (widget, "interior-focus", interior_focus, - "focus-line-width", focus_width, NULL); - - if (interior_focus) - { - *xborder += *focus_width; - *yborder += *focus_width; - } -} - -/* GTK+/ GtkEntry internal helper function - Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - Modified by the GTK+ Team and others 1997-2000 - Copied from Gtk+ 2.13, whitespace adjusted */ -static void -gtk_entry_get_text_area_size (GtkEntry *entry, - gint *x, - gint *y, - gint *width, - gint *height) -{ - gint frame_height; - gint xborder, yborder; - gboolean interior_focus; - gint focus_width; - GtkRequisition requisition; - GtkWidget *widget = GTK_WIDGET (entry); - - gtk_widget_get_child_requisition (widget, &requisition); - gtk_entry_borders (entry, &xborder, &yborder, &interior_focus, &focus_width); - - if (GTK_WIDGET_REALIZED (widget)) - gdk_drawable_get_size (widget->window, NULL, &frame_height); - else - frame_height = requisition.height; - - if (GTK_WIDGET_HAS_FOCUS (widget) && interior_focus) - frame_height -= 2 * focus_width; - - if (x) - *x = xborder; - - if (y) - *y = frame_height / 2 - (requisition.height - yborder * 2) / 2; - - if (width) - *width = GTK_WIDGET (entry)->allocation.width - xborder * 2; - - if (height) - *height = requisition.height - yborder * 2; -} - -/* GTK+/ GtkEntry internal helper function - Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - Modified by the GTK+ Team and others 1997-2000 - Copied from Gtk+ 2.13, whitespace adjusted */ -static void -get_layout_position (GtkEntry *entry, - gint *x, - gint *y) -{ - PangoLayout *layout; - PangoRectangle logical_rect; - gint area_width, area_height; - GtkBorder inner_border; - gint y_pos; - PangoLayoutLine *line; - - layout = gtk_entry_get_layout (entry); - - gtk_entry_get_text_area_size (entry, NULL, NULL, &area_width, &area_height); - _gtk_entry_effective_inner_border (entry, &inner_border); - - area_height = PANGO_SCALE * - (area_height - inner_border.top - inner_border.bottom); - - line = pango_layout_get_lines (layout)->data; - pango_layout_line_get_extents (line, NULL, &logical_rect); - - /* Align primarily for locale's ascent/descent */ - y_pos = ((area_height - entry->ascent - entry->descent) / 2 + - entry->ascent + logical_rect.y); - - /* Now see if we need to adjust to fit in actual drawn string */ - if (logical_rect.height > area_height) - y_pos = (area_height - logical_rect.height) / 2; - else if (y_pos < 0) - y_pos = 0; - else if (y_pos + logical_rect.height > area_height) - y_pos = area_height - logical_rect.height; - - y_pos = inner_border.top + y_pos / PANGO_SCALE; - - if (x) - *x = inner_border.left - entry->scroll_offset; - - if (y) - *y = y_pos; -} - -/* GTK+/ GtkEntry internal helper function - Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - Modified by the GTK+ Team and others 1997-2000 - Copied from Gtk+ 2.13, whitespace adjusted - Code adjusted to not rely on internal _gtk_entry_ensure_layout */ -static void -gtk_entry_draw_text (GtkEntry *entry) -{ - GtkWidget *widget; - - if (!entry->visible && entry->invisible_char == 0) - return; - - if (GTK_WIDGET_DRAWABLE (entry)) - { - PangoLayout *layout = gtk_entry_get_layout (entry); - cairo_t *cr; - gint x, y; - gint start_pos, end_pos; - - widget = GTK_WIDGET (entry); - - get_layout_position (entry, &x, &y); - - cr = gdk_cairo_create (entry->text_area); - - cairo_move_to (cr, x, y); - gdk_cairo_set_source_color (cr, &widget->style->text [widget->state]); - pango_cairo_show_layout (cr, layout); - - if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), - &start_pos, &end_pos)) - { - gint *ranges; - gint n_ranges, i; - PangoRectangle logical_rect; - GdkColor *selection_color, *text_color; - GtkBorder inner_border; - - pango_layout_get_pixel_extents (layout, NULL, &logical_rect); - gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges); - - if (GTK_WIDGET_HAS_FOCUS (entry)) - { - selection_color = &widget->style->base [GTK_STATE_SELECTED]; - text_color = &widget->style->text [GTK_STATE_SELECTED]; - } - else - { - selection_color = &widget->style->base [GTK_STATE_ACTIVE]; - text_color = &widget->style->text [GTK_STATE_ACTIVE]; - } - - _gtk_entry_effective_inner_border (entry, &inner_border); - - for (i = 0; i < n_ranges; ++i) - cairo_rectangle (cr, - inner_border.left - - entry->scroll_offset + ranges[2 * i], - y, - ranges[2 * i + 1], - logical_rect.height); - - cairo_clip (cr); - - gdk_cairo_set_source_color (cr, selection_color); - cairo_paint (cr); - - cairo_move_to (cr, x, y); - gdk_cairo_set_source_color (cr, text_color); - pango_cairo_show_layout (cr, layout); - - g_free (ranges); - } - - cairo_destroy (cr); - } -} - -static gboolean -entry_expose_event (GtkWidget* entry, - GdkEventExpose* event, - GtkIconEntry* icon_entry) -{ - GtkIconEntryPrivate *priv; - GdkWindow* text_area; - gint width, height; - - priv = icon_entry->priv; - text_area = GTK_ENTRY (entry)->text_area; - gdk_drawable_get_size (text_area, &width, &height); - - if (priv->fraction > 0.0) - { - gtk_paint_box (entry->style, text_area, - GTK_STATE_SELECTED, GTK_SHADOW_OUT, - &event->area, entry, "entry-progress", - 0, 0, priv->fraction * width, height); - gtk_entry_draw_text (GTK_ENTRY (entry)); - } - return FALSE; -} - -static void -gtk_icon_entry_init (GtkIconEntry *entry) -{ - entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry, GTK_TYPE_ICON_ENTRY, - GtkIconEntryPrivate); - - g_signal_connect_after (entry, "expose-event", - G_CALLBACK (entry_expose_event), entry); -} - -static void -gtk_icon_entry_finalize (GObject *obj) -{ - GtkIconEntry *entry; - - g_return_if_fail (obj != NULL); - g_return_if_fail (GTK_IS_ICON_ENTRY(obj)); - - entry = GTK_ICON_ENTRY (obj); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -static void -gtk_icon_entry_dispose (GObject *obj) -{ - GtkIconEntry *entry; - - entry = GTK_ICON_ENTRY (obj); - - gtk_icon_entry_set_icon_from_pixbuf (entry, GTK_ICON_ENTRY_PRIMARY, NULL); - gtk_icon_entry_set_icon_from_pixbuf (entry, GTK_ICON_ENTRY_SECONDARY, NULL); - - G_OBJECT_CLASS (parent_class)->dispose (obj); -} - -static void -gtk_icon_entry_map (GtkWidget *widget) -{ - GtkIconEntryPrivate *priv; - GdkCursor *cursor; - - if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_MAPPED (widget)) - { - int i; - - GTK_WIDGET_CLASS (parent_class)->map (widget); - - priv = GTK_ICON_ENTRY (widget)->priv; - - for (i = 0; i < MAX_ICONS; i++) - { - if (priv->icons[i].pixbuf != NULL) - gdk_window_show (priv->icons[i].window); - - if (priv->icons[i].custom_cursor == TRUE && !priv->icons[i].insensitive) - { - cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), - priv->icons[i].cursor_type); - - gdk_window_set_cursor (priv->icons[i].window, cursor); - gdk_cursor_unref (cursor); - } - } - - GTK_WIDGET_CLASS (parent_class)->map (widget); - } -} - -static void -gtk_icon_entry_unmap (GtkWidget *widget) -{ - GtkIconEntryPrivate *priv; - - if (GTK_WIDGET_MAPPED (widget)) - { - int i; - - priv = GTK_ICON_ENTRY (widget)->priv; - - for (i = 0; i < MAX_ICONS; i++) - { - if (priv->icons[i].pixbuf != NULL) - { - gdk_window_hide (priv->icons[i].window); - } - } - - GTK_WIDGET_CLASS (parent_class)->unmap (widget); - } -} - -static void -gtk_icon_entry_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkIconEntry *entry = GTK_ICON_ENTRY (object); - - switch (prop_id) - { - case PROP_PIXBUF_PRIMARY: - gtk_icon_entry_set_icon_from_pixbuf (entry, - GTK_ICON_ENTRY_PRIMARY, - g_value_get_object (value)); - break; - - case PROP_PIXBUF_SECONDARY: - gtk_icon_entry_set_icon_from_pixbuf (entry, - GTK_ICON_ENTRY_SECONDARY, - g_value_get_object (value)); - break; - - case PROP_STOCK_PRIMARY: - gtk_icon_entry_set_icon_from_stock (entry, - GTK_ICON_ENTRY_PRIMARY, - g_value_get_string (value)); - break; - - case PROP_STOCK_SECONDARY: - gtk_icon_entry_set_icon_from_stock (entry, - GTK_ICON_ENTRY_SECONDARY, - g_value_get_string (value)); - break; - - case PROP_ICON_NAME_PRIMARY: - gtk_icon_entry_set_icon_from_icon_name (entry, - GTK_ICON_ENTRY_PRIMARY, - g_value_get_string (value)); - break; - - case PROP_ICON_NAME_SECONDARY: - gtk_icon_entry_set_icon_from_icon_name (entry, - GTK_ICON_ENTRY_SECONDARY, - g_value_get_string (value)); - break; - - case PROP_GICON_PRIMARY: - gtk_icon_entry_set_icon_from_gicon (entry, - GTK_ICON_ENTRY_PRIMARY, - g_value_get_object (value)); - break; - - case PROP_GICON_SECONDARY: - gtk_icon_entry_set_icon_from_gicon (entry, - GTK_ICON_ENTRY_SECONDARY, - g_value_get_object (value)); - break; - } -} - -static void -gtk_icon_entry_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkIconEntry *entry = GTK_ICON_ENTRY (object); - - switch (prop_id) - { - case PROP_PIXBUF_PRIMARY: - g_value_set_object (value, - gtk_icon_entry_get_pixbuf (entry, - GTK_ICON_ENTRY_PRIMARY)); - break; - - case PROP_PIXBUF_SECONDARY: - g_value_set_object (value, - gtk_icon_entry_get_pixbuf (entry, - GTK_ICON_ENTRY_SECONDARY)); - break; - - case PROP_GICON_PRIMARY: - g_value_set_object (value, - gtk_icon_entry_get_gicon (entry, - GTK_ICON_ENTRY_PRIMARY)); - break; - - case PROP_GICON_SECONDARY: - g_value_set_object (value, - gtk_icon_entry_get_gicon (entry, - GTK_ICON_ENTRY_SECONDARY)); - } -} - -static gint -get_icon_width (GtkIconEntry *entry, GtkIconEntryPosition icon_pos) -{ - gint menu_icon_width; - gint width; - GtkIconEntryPrivate *priv; - EntryIconInfo *icon_info; - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - if (icon_info->pixbuf == NULL) - return 0; - - gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &menu_icon_width, NULL); - - width = MAX (gdk_pixbuf_get_width (icon_info->pixbuf), menu_icon_width); - - return width; -} - -static void -get_borders (GtkIconEntry *entry, gint *xborder, gint *yborder) -{ - GtkWidget *widget = GTK_WIDGET (entry); - gint focus_width; - gboolean interior_focus; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - NULL); - - if (gtk_entry_get_has_frame (GTK_ENTRY (entry))) - { - *xborder = widget->style->xthickness; - *yborder = widget->style->ythickness; - } - else - { - *xborder = 0; - *yborder = 0; - } - - if (!interior_focus) - { - *xborder += focus_width; - *yborder += focus_width; - } -} - -static void -get_text_area_size (GtkIconEntry *entry, GtkAllocation *alloc) -{ - GtkWidget *widget = GTK_WIDGET (entry); - GtkRequisition requisition; - gint xborder, yborder; - - gtk_widget_get_child_requisition (widget, &requisition); - get_borders (entry, &xborder, &yborder); - - alloc->x = xborder; - alloc->y = yborder; - alloc->width = widget->allocation.width - xborder * 2; - alloc->height = requisition.height - yborder * 2; -} - -static void -get_icon_allocation (GtkIconEntry *icon_entry, - gboolean left, - GtkAllocation *widget_alloc, - GtkAllocation *text_area_alloc, - GtkAllocation *allocation, - GtkIconEntryPosition *icon_pos) -{ - gboolean rtl; - - rtl = (gtk_widget_get_direction (GTK_WIDGET (icon_entry)) == - GTK_TEXT_DIR_RTL); - - if (left) - *icon_pos = (rtl ? GTK_ICON_ENTRY_SECONDARY : GTK_ICON_ENTRY_PRIMARY); - else - *icon_pos = (rtl ? GTK_ICON_ENTRY_PRIMARY : GTK_ICON_ENTRY_SECONDARY); - - allocation->y = text_area_alloc->y; - allocation->width = get_icon_width(icon_entry, *icon_pos); - allocation->height = text_area_alloc->height; - - if (left) - { - allocation->x = text_area_alloc->x + ICON_MARGIN; - } - else - { - allocation->x = text_area_alloc->x + text_area_alloc->width - - allocation->width - ICON_MARGIN; - } -} - -static void -gtk_icon_entry_realize (GtkWidget *widget) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - GdkWindowAttr attributes; - gint attributes_mask; - int i; - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - - GTK_WIDGET_CLASS (parent_class)->realize (widget); - - attributes.x = 0; - attributes.y = 0; - attributes.width = 1; - attributes.height = 1; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= - (GDK_EXPOSURE_MASK - | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - for (i = 0; i < MAX_ICONS; i++) - { - EntryIconInfo *icon_info; - - icon_info = &priv->icons[i]; - icon_info->window = gdk_window_new (widget->window, &attributes, - attributes_mask); - gdk_window_set_user_data (icon_info->window, widget); - - gdk_window_set_background (icon_info->window, - &widget->style->base[GTK_WIDGET_STATE(widget)]); - } - - gtk_widget_queue_resize (widget); -} - -static void -gtk_icon_entry_unrealize (GtkWidget *widget) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - int i; - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); - - for (i = 0; i < MAX_ICONS; i++) - { - EntryIconInfo *icon_info = &priv->icons[i]; - - gdk_window_destroy (icon_info->window); - icon_info->window = NULL; - } -} - -static void -gtk_icon_entry_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - GtkEntry *gtkentry; - GtkIconEntry *entry; - gint icon_widths = 0; - int i; - - gtkentry = GTK_ENTRY(widget); - entry = GTK_ICON_ENTRY(widget); - - for (i = 0; i < MAX_ICONS; i++) - { - int icon_width = get_icon_width (entry, i); - - if (icon_width > 0) - { - icon_widths += icon_width + ICON_MARGIN; - } - } - - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); - - if (icon_widths > requisition->width) - requisition->width += icon_widths; -} - -static void -place_windows (GtkIconEntry *icon_entry, GtkAllocation *widget_alloc) -{ - GtkIconEntryPosition left_icon_pos; - GtkIconEntryPosition right_icon_pos; - GtkAllocation left_icon_alloc; - GtkAllocation right_icon_alloc; - GtkAllocation text_area_alloc; - GtkIconEntryPrivate *priv; - gint y; - - priv = icon_entry->priv; - - get_text_area_size (icon_entry, &text_area_alloc); - - /* DJW center text/icon - * TODO flicker needs to be eliminated - */ - gdk_window_get_geometry (GTK_ENTRY (icon_entry)->text_area, NULL, &y, NULL, NULL, NULL); - text_area_alloc.y = y; - - get_icon_allocation (icon_entry, TRUE, widget_alloc, &text_area_alloc, - &left_icon_alloc, &left_icon_pos); - get_icon_allocation (icon_entry, FALSE, widget_alloc, &text_area_alloc, - &right_icon_alloc, &right_icon_pos); - - if (left_icon_alloc.width > 0) - { - text_area_alloc.x = left_icon_alloc.x + left_icon_alloc.width + ICON_MARGIN; - } - - if (right_icon_alloc.width > 0) - { - text_area_alloc.width -= right_icon_alloc.width + ICON_MARGIN; - } - - text_area_alloc.width -= text_area_alloc.x; - - gdk_window_move_resize (priv->icons[left_icon_pos].window, - left_icon_alloc.x, left_icon_alloc.y, - left_icon_alloc.width, left_icon_alloc.height); - - gdk_window_move_resize (priv->icons[right_icon_pos].window, - right_icon_alloc.x, right_icon_alloc.y, - right_icon_alloc.width, right_icon_alloc.height); - - gdk_window_move_resize (GTK_ENTRY (icon_entry)->text_area, - text_area_alloc.x, text_area_alloc.y, - text_area_alloc.width, text_area_alloc.height); -} - -static void -gtk_icon_entry_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - g_return_if_fail (GTK_IS_ICON_ENTRY(widget)); - g_return_if_fail (allocation != NULL); - - widget->allocation = *allocation; - - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); - - if (GTK_WIDGET_REALIZED (widget)) - place_windows (GTK_ICON_ENTRY (widget), allocation); -} - -static GdkPixbuf * -get_pixbuf_from_icon (GtkIconEntry *entry, GtkIconEntryPosition icon_pos) -{ - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - g_object_ref (icon_info->pixbuf); - - return icon_info->pixbuf; -} - -/* Kudos to the gnome-panel guys. */ -static void -colorshift_pixbuf (GdkPixbuf *dest, GdkPixbuf *src, int shift) -{ - gint i, j; - gint width, height, has_alpha, src_rowstride, dest_rowstride; - guchar *target_pixels; - guchar *original_pixels; - guchar *pix_src; - guchar *pix_dest; - int val; - guchar r, g, b; - - has_alpha = gdk_pixbuf_get_has_alpha (src); - width = gdk_pixbuf_get_width (src); - height = gdk_pixbuf_get_height (src); - src_rowstride = gdk_pixbuf_get_rowstride (src); - dest_rowstride = gdk_pixbuf_get_rowstride (dest); - original_pixels = gdk_pixbuf_get_pixels (src); - target_pixels = gdk_pixbuf_get_pixels (dest); - - for (i = 0; i < height; i++) - { - pix_dest = target_pixels + i * dest_rowstride; - pix_src = original_pixels + i * src_rowstride; - - for (j = 0; j < width; j++) - { - r = *(pix_src++); - g = *(pix_src++); - b = *(pix_src++); - - val = r + shift; - *(pix_dest++) = CLAMP(val, 0, 255); - - val = g + shift; - *(pix_dest++) = CLAMP(val, 0, 255); - - val = b + shift; - *(pix_dest++) = CLAMP(val, 0, 255); - - if (has_alpha) - *(pix_dest++) = *(pix_src++); - } - } -} - -static void -draw_icon (GtkWidget *widget, GtkIconEntryPosition icon_pos) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - EntryIconInfo *icon_info; - GdkPixbuf *pixbuf; - gint x, y, width, height; - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - if (icon_info->pixbuf == NULL || !GTK_WIDGET_REALIZED (widget)) - return; - - if ((pixbuf = get_pixbuf_from_icon (entry, icon_pos)) == NULL) - return; - - gdk_drawable_get_size (icon_info->window, &width, &height); - - if (width == 1 || height == 1) - { - /* - * size_allocate hasn't been called yet. These are the default values. - */ - return; - } - - if (gdk_pixbuf_get_height (pixbuf) > height) - { - GdkPixbuf *temp_pixbuf; - int scale; - - scale = height - (2 * ICON_MARGIN); - - temp_pixbuf = gdk_pixbuf_scale_simple (pixbuf, scale, scale, - GDK_INTERP_BILINEAR); - - g_object_unref (pixbuf); - - pixbuf = temp_pixbuf; - } - - x = (width - gdk_pixbuf_get_width(pixbuf)) / 2; - y = (height - gdk_pixbuf_get_height(pixbuf)) / 2; - - if (icon_info->insensitive) - { - GdkPixbuf *temp_pixbuf; - - temp_pixbuf = gdk_pixbuf_copy (pixbuf); - - gdk_pixbuf_saturate_and_pixelate (pixbuf, - temp_pixbuf, - 0.8f, - TRUE); - g_object_unref (pixbuf); - pixbuf = temp_pixbuf; - } - else if (icon_info->hovered) - { - GdkPixbuf *temp_pixbuf; - - temp_pixbuf = gdk_pixbuf_copy (pixbuf); - - colorshift_pixbuf (temp_pixbuf, pixbuf, 30); - - g_object_unref (pixbuf); - - pixbuf = temp_pixbuf; - } - - gdk_draw_pixbuf (icon_info->window, widget->style->black_gc, pixbuf, - 0, 0, x, y, -1, -1, - GDK_RGB_DITHER_NORMAL, 0, 0); - - g_object_unref (pixbuf); -} - -static gint -gtk_icon_entry_expose (GtkWidget *widget, GdkEventExpose *event) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - - g_return_val_if_fail (GTK_IS_ICON_ENTRY (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - - if (GTK_WIDGET_DRAWABLE (widget)) - { - gboolean found = FALSE; - int i; - - for (i = 0; i < MAX_ICONS && !found; i++) - { - EntryIconInfo *icon_info = &priv->icons[i]; - - if (event->window == icon_info->window) - { - gint width; - GtkAllocation text_area_alloc; - - get_text_area_size (entry, &text_area_alloc); - gdk_drawable_get_size (icon_info->window, &width, NULL); - - gtk_paint_flat_box (widget->style, icon_info->window, - GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, - NULL, widget, "entry_bg", - 0, 0, width, text_area_alloc.height); - - draw_icon (widget, i); - - found = TRUE; - } - } - - if (!found) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - } - - return FALSE; -} - -static gint -gtk_icon_entry_enter_notify (GtkWidget *widget, GdkEventCrossing *event) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - int i; - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - - for (i = 0; i < MAX_ICONS; i++) - { - if (event->window == priv->icons[i].window) - { - if (gtk_icon_entry_get_icon_highlight (entry, i)) - { - priv->icons[i].hovered = TRUE; - - if (priv->icons[i].tooltip_text != NULL) - { - gtk_widget_set_tooltip_text (widget, - priv->icons[i].tooltip_text); - gtk_widget_set_has_tooltip (widget, TRUE); - } else { - gtk_widget_set_has_tooltip (widget, FALSE); - } - - gtk_widget_queue_draw (widget); - - break; - } - } - } - - return FALSE; -} - -static gint -gtk_icon_entry_leave_notify (GtkWidget *widget, GdkEventCrossing *event) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - int i; - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - - for (i = 0; i < MAX_ICONS; i++) - { - if (event->window == priv->icons[i].window) - { - if (gtk_icon_entry_get_icon_highlight (entry, i)) - { - priv->icons[i].hovered = FALSE; - - gtk_widget_set_has_tooltip (widget, FALSE); - gtk_widget_queue_draw (widget); - - break; - } - } - } - - return FALSE; -} - -static gint -gtk_icon_entry_button_press (GtkWidget *widget, GdkEventButton *event) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - int i; - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - - for (i = 0; i < MAX_ICONS; i++) - { - if (event->window == priv->icons[i].window) - { - if (event->button == 1 && gtk_icon_entry_get_icon_highlight (entry, i)) - { - priv->icons[i].hovered = FALSE; - - gtk_widget_queue_draw (widget); - } - - g_signal_emit (entry, signals[ICON_PRESSED], 0, i, event->button); - - return TRUE; - } - } - - if (GTK_WIDGET_CLASS (parent_class)->button_press_event) - return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); - - return FALSE; -} - -static gint -gtk_icon_entry_button_release (GtkWidget *widget, GdkEventButton *event) -{ - GtkIconEntry *entry; - GtkIconEntryPrivate *priv; - int i; - - entry = GTK_ICON_ENTRY (widget); - priv = entry->priv; - - for (i = 0; i < MAX_ICONS; i++) - { - GdkWindow *icon_window = priv->icons[i].window; - - if (event->window == icon_window) - { - int width, height; - gdk_drawable_get_size (icon_window, &width, &height); - - if (event->button == 1 && - gtk_icon_entry_get_icon_highlight (entry, i) && - event->x >= 0 && event->y >= 0 && - event->x <= width && event->y <= height) - { - priv->icons[i].hovered = TRUE; - - gtk_widget_queue_draw (widget); - } - - g_signal_emit (entry, signals[ICON_RELEASED], 0, i, event->button); - - return TRUE; - } - } - - if (GTK_WIDGET_CLASS (parent_class)->button_release_event) - return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event); - - return FALSE; -} - -static void -gtk_icon_entry_style_set (GtkWidget *widget, GtkStyle *prev_style) -{ - GtkIconEntry *icon_entry; - - icon_entry = GTK_ICON_ENTRY (widget); - - if (GTK_WIDGET_CLASS (gtk_icon_entry_parent_class)->style_set) - GTK_WIDGET_CLASS (gtk_icon_entry_parent_class)->style_set (widget, prev_style); - - icon_theme_changed (icon_entry); -} - -static void -icon_theme_changed (GtkIconEntry *entry) -{ - GtkIconEntryPrivate *priv; - int i; - - priv = entry->priv; - - for (i = 0; i < MAX_ICONS; i++) - { - if (priv->icons[i].storage_type == GTK_IMAGE_ICON_NAME) - { - g_object_unref (priv->icons[i].pixbuf); - priv->icons[i].pixbuf = NULL; - - gtk_icon_entry_set_icon_from_icon_name (entry, i, priv->icons[i].icon_name); - } - else if (priv->icons[i].storage_type == _GTK_IMAGE_GICON) - { - g_object_unref (priv->icons[i].pixbuf); - priv->icons[i].pixbuf = NULL; - - gtk_icon_entry_set_icon_from_gicon (entry, i, priv->icons[i].gicon); - } - } - - gtk_widget_queue_draw (GTK_WIDGET (entry)); -} - -static void -gtk_icon_entry_set_icon_internal (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - GdkPixbuf *pixbuf) -{ - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - - g_return_if_fail (entry != NULL); - g_return_if_fail (GTK_IS_ICON_ENTRY (entry)); - g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos)); - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - if (pixbuf == icon_info->pixbuf) - return; - - if (icon_pos == GTK_ICON_ENTRY_SECONDARY && - priv->icon_released_id != 0) - { - g_signal_handler_disconnect (entry, priv->icon_released_id); - priv->icon_released_id = 0; - } - - if (pixbuf == NULL) - { - if (icon_info->pixbuf != NULL) - { - g_object_unref (icon_info->pixbuf); - icon_info->pixbuf = NULL; - - /* Explicitly check, as the pointer may become invalidated - * during destruction. - */ - if (icon_info->window != NULL && GDK_IS_WINDOW (icon_info->window)) - gdk_window_hide (icon_info->window); - } - } - else - { - if (icon_info->window != NULL && icon_info->pixbuf == NULL) - gdk_window_show (icon_info->window); - - icon_info->pixbuf = pixbuf; - g_object_ref (pixbuf); - } - - gtk_widget_queue_draw (GTK_WIDGET (entry)); -} - -/** - * gtk_icon_entry_new - * - * Creates a new GtkIconEntry widget. - * - * Returns a new #GtkIconEntry. - */ -GtkWidget * -gtk_icon_entry_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_ICON_ENTRY, NULL)); -} - -/** - * gtk_icon_entry_set_icon_from_pixbuf - * @entry: A #GtkIconEntry. - * @position: Icon position. - * @pixbuf: A #GdkPixbuf. - * - * Sets the icon shown in the specified position using a pixbuf. - */ -void -gtk_icon_entry_set_icon_from_pixbuf (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - GdkPixbuf *pixbuf) -{ - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - - g_return_if_fail (entry != NULL); - g_return_if_fail (GTK_IS_ICON_ENTRY (entry)); - g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos)); - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - if (pixbuf == icon_info->pixbuf) - return; - - if (icon_pos == GTK_ICON_ENTRY_SECONDARY && - priv->icon_released_id != 0) - { - g_signal_handler_disconnect (entry, priv->icon_released_id); - priv->icon_released_id = 0; - } - - if (pixbuf == NULL) - { - if (icon_info->pixbuf != NULL) - { - g_object_unref (icon_info->pixbuf); - icon_info->pixbuf = NULL; - - /* Explicitly check, as the pointer may become invalidated - * during destruction. - */ - if (icon_info->window != NULL && GDK_IS_WINDOW (icon_info->window)) - gdk_window_hide (icon_info->window); - } - } - else - { - if (icon_info->window != NULL && icon_info->pixbuf == NULL) - gdk_window_show (icon_info->window); - - icon_info->pixbuf = pixbuf; - g_object_ref (pixbuf); - } - - gtk_widget_queue_draw (GTK_WIDGET (entry)); -} - -/** - * gtk_icon_entry_set_icon_from_stock - * @entry: A #GtkIconEntry. - * @position: Icon position. - * @stock_id: The name of the stock item. - * - * Sets the icon shown in the entry at the specified position from a stock image. - */ -void -gtk_icon_entry_set_icon_from_stock (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - const gchar *stock_id) -{ - GdkPixbuf *pixbuf; - - /* FIXME: Due to a bug in GtkIconEntry we need to set a non-NULL icon */ - if (! stock_id) - stock_id = GTK_STOCK_INFO; - - pixbuf = gtk_widget_render_icon (GTK_WIDGET (entry), - stock_id, - GTK_ICON_SIZE_MENU, - NULL); - - gtk_icon_entry_set_icon_internal (entry, - icon_pos, - pixbuf); -} - -/** - * gtk_icon_entry_set_icon_from_icon_name - * @entry: A #GtkIconEntry; - * @icon_pos: The position at which to set the icon - * @icon_name: An icon name - * - * Sets the icon shown in the entry at the specified position from the current - * icon theme. If the icon name isn't known, a "broken image" icon will be - * displayed instead. If the current icon theme is changed, the icon will be - * updated appropriately. - */ -void -gtk_icon_entry_set_icon_from_icon_name (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - const gchar *icon_name) -{ - GdkPixbuf *pixbuf = NULL; - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - GdkScreen *screen; - GtkIconTheme *icon_theme; - GtkSettings *settings; - gint width, height; - GError *error = NULL; - - g_return_if_fail (entry != NULL); - g_return_if_fail (GTK_IS_ICON_ENTRY (entry)); - g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos)); - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - screen = gtk_widget_get_screen (GTK_WIDGET (entry)); - icon_theme = gtk_icon_theme_get_for_screen (screen); - settings = gtk_settings_get_for_screen (screen); - - if (icon_name != NULL) - { - gtk_icon_size_lookup_for_settings (settings, - GTK_ICON_SIZE_MENU, - &width, &height); - - pixbuf = gtk_icon_theme_load_icon (icon_theme, - icon_name, - MIN (width, height), 0, &error); - - if (pixbuf == NULL) - { - g_error_free (error); - pixbuf = gtk_widget_render_icon (GTK_WIDGET (entry), - GTK_STOCK_MISSING_IMAGE, - GTK_ICON_SIZE_MENU, - NULL); - } - } - - gtk_icon_entry_set_icon_internal (entry, - icon_pos, - pixbuf); -} - -/** - * gtk_icon_entry_set_icon_from_gicon - * @entry: A #GtkIconEntry; - * @icon_pos: The position at which to set the icon - * @icon: The icon to set - * - * Sets the icon shown in the entry at the specified position from the current - * icon theme. If the icon isn't known, a "broken image" icon will be displayed - * instead. If the current icon theme is changed, the icon will be updated - * appropriately. - */ -void -gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - GIcon *icon) -{ - GdkPixbuf *pixbuf = NULL; - GtkIconEntryPrivate *priv; - EntryIconInfo *icon_info; - GdkScreen *screen; - GtkIconTheme *icon_theme; - GtkSettings *settings; - gint width, height; - GError *error = NULL; - GtkIconInfo *info; - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - screen = gtk_widget_get_screen (GTK_WIDGET (entry)); - icon_theme = gtk_icon_theme_get_for_screen (screen); - settings = gtk_settings_get_for_screen (screen); - - if (icon != NULL) - { - gtk_icon_size_lookup_for_settings (settings, - GTK_ICON_SIZE_MENU, - &width, &height); - - #if GTK_CHECK_VERSION (2, 14, 0) - info = gtk_icon_theme_lookup_by_gicon (icon_theme, - icon, - MIN (width, height), 0); - #else - info = NULL; - #endif - pixbuf = gtk_icon_info_load_icon (info, &error); - if (pixbuf == NULL) - { - g_error_free (error); - pixbuf = gtk_widget_render_icon (GTK_WIDGET (entry), - GTK_STOCK_MISSING_IMAGE, - GTK_ICON_SIZE_MENU, - NULL); - } - } - - gtk_icon_entry_set_icon_internal ((GtkIconEntry*)entry, - icon_pos, - pixbuf); -} - -/** - * gtk_icon_entry_set_cursor - * @entry: A #GtkIconEntry; - * @icon_pos: The position at which to set the cursor - * @cursor_type: A #GdkCursorType; describing the cursor to set - * - * Sets an alternate mouse cursor used for the specified icon. - */ -void -gtk_icon_entry_set_cursor (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - GdkCursorType cursor_type) -{ - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - GdkCursor *cursor; - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - icon_info->cursor_type = cursor_type; - icon_info->custom_cursor = TRUE; - - if (GTK_WIDGET_REALIZED (GTK_WIDGET (entry))) - { - cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (entry)), - cursor_type); - - gdk_window_set_cursor (icon_info->window, cursor); - gdk_cursor_unref (cursor); - } -} - -/** - * gtk_icon_entry_set_icon_highlight - * @entry: A #GtkIconEntry; - * @position: Icon position. - * @highlight: TRUE if the icon should highlight on mouse-over - * - * Determines whether the icon will highlight on mouse-over. - */ -void -gtk_icon_entry_set_icon_highlight (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - gboolean highlight) -{ - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - - priv = entry->priv; - - g_return_if_fail (entry != NULL); - g_return_if_fail (GTK_IS_ICON_ENTRY (entry)); - g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos)); - - icon_info = &priv->icons[icon_pos]; - - if (icon_info->highlight == highlight) - return; - - icon_info->highlight = highlight; -} - -/** - * gtk_icon_entry_get_pixbuf - * @entry: A #GtkIconEntry. - * @position: Icon position. - * - * Retrieves the image used for the icon. Unlike the other methods of setting - * and getting icon data, this method will work regardless of whether the icon - * was set using a #GdkPixbuf, a #GIcon, a stock item, or an icon name. - * - * Returns: A #GdkPixbuf, or NULL if no icon is set for this position. - */ -GdkPixbuf * -gtk_icon_entry_get_pixbuf (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos) -{ - GtkIconEntryPrivate *priv; - - g_return_val_if_fail (entry != NULL, NULL); - g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), NULL); - g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), NULL); - - priv = entry->priv; - - return priv->icons[icon_pos].pixbuf; -} - -/** - * gtk_icon_entry_get_gicon - * @entry: A #GtkIconEntry - * @position: Icon position. - * - * Retrieves the GIcon used for the icon, or NULL if there is no icon or if - * the icon was set by some other method (e.g., by stock, pixbuf, or icon name). - * - * Returns: A #GIcon, or NULL if no icon is set or if the icon is not a GIcon. - */ -GIcon * -gtk_icon_entry_get_gicon (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos) -{ - GtkIconEntryPrivate *priv; - EntryIconInfo *icon_info; - - g_return_val_if_fail (entry != NULL, NULL); - g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), NULL); - g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), NULL); - - priv = entry->priv; - icon_info = &priv->icons[icon_pos]; - - return icon_info->storage_type == _GTK_IMAGE_GICON ? icon_info->gicon : NULL; -} - -/** - * gtk_icon_entry_get_icon_highlight - * @entry: A #GtkIconEntry. - * @position: Icon position. - * - * Retrieves whether entry will highlight the icon on mouseover. - * - * Returns: TRUE if icon highlights. - */ -gboolean -gtk_icon_entry_get_icon_highlight (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos) -{ - GtkIconEntryPrivate *priv; - - g_return_val_if_fail (entry != NULL, FALSE); - g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), FALSE); - g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), FALSE); - - priv = entry->priv; - - return priv->icons[icon_pos].highlight; -} - -/** - * gtk_icon_entry_set_tooltip - * @entry: A #GtkIconEntry. - * @position: Icon position. - * @text: The text to be used for the tooltip. - * - * Sets the tooltip text used for the specified icon. - */ -void -gtk_icon_entry_set_tooltip (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - const gchar *text) -{ - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - gchar *new_tooltip; - - g_return_if_fail (entry != NULL); - g_return_if_fail (GTK_IS_ICON_ENTRY (entry)); - g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos)); - - priv = entry->priv; - - icon_info = &priv->icons[icon_pos]; - - new_tooltip = g_strdup (text); - if (icon_info->tooltip_text != NULL) - g_free (icon_info->tooltip_text); - icon_info->tooltip_text = new_tooltip; -} - -const gchar* -gtk_icon_entry_get_icon_tooltip (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos) -{ - g_return_val_if_fail (entry != NULL, FALSE); - g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), FALSE); - g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), FALSE); - - return entry->priv->icons[icon_pos].tooltip_text; -} - -/** - * gtk_icon_entry_set_icon_sensitive - * @entry: A #GtkIconEntry. - * @position: Icon position. - * @sensitive: Specifies whether the icon should appear sensitive or insensitive. - * - * Sets the sensitivity for the specified icon. - */ -void -gtk_icon_entry_set_icon_sensitive (const GtkIconEntry *icon_entry, - GtkIconEntryPosition icon_pos, - gboolean sensitive) -{ - EntryIconInfo *icon_info; - GtkIconEntryPrivate *priv; - - g_return_if_fail (icon_entry != NULL); - g_return_if_fail (GTK_IS_ICON_ENTRY (icon_entry)); - g_return_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos)); - - priv = icon_entry->priv; - - icon_info = &priv->icons[icon_pos]; - - icon_info->insensitive = !sensitive; - - if (icon_info->custom_cursor == TRUE && GTK_WIDGET_REALIZED (GTK_WIDGET (icon_entry))) - { - GdkCursor *cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (icon_entry)), - sensitive ? icon_info->cursor_type : GDK_ARROW); - gdk_window_set_cursor (icon_info->window, cursor); - gdk_cursor_unref (cursor); - } -} - -void -gtk_icon_entry_set_progress_fraction (GtkIconEntry *icon_entry, - gdouble fraction) -{ - GtkIconEntryPrivate *priv; - - g_return_if_fail (GTK_IS_ICON_ENTRY (icon_entry)); - - priv = icon_entry->priv; - priv->fraction = CLAMP (fraction, 0.0, 1.0); - - if (GTK_ENTRY (icon_entry)->text_area) - gdk_window_invalidate_rect (GTK_ENTRY (icon_entry)->text_area, NULL, FALSE); -} - -#endif diff --git a/midori/gtkiconentry.h b/midori/gtkiconentry.h index 76019d57..daa1819d 100644 --- a/midori/gtkiconentry.h +++ b/midori/gtkiconentry.h @@ -26,7 +26,6 @@ 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 @@ -45,99 +44,6 @@ G_BEGIN_DECLS #define gtk_icon_entry_get_tooltip gtk_entry_get_icon_tooltip_text #define gtk_icon_entry_set_icon_highlight gtk_entry_set_icon_activatable #define gtk_icon_entry_set_progress_fraction gtk_entry_set_progress_fraction -#else - -#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_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_ICON_ENTRY, GtkIconEntryClass)) -#define GTK_IS_ICON_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_ICON_ENTRY)) -#define GTK_IS_ICON_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_ICON_ENTRY)) -#define GTK_ICON_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_ENTRY, GtkIconEntryClass)) - -typedef enum -{ - GTK_ICON_ENTRY_PRIMARY, - GTK_ICON_ENTRY_SECONDARY -} GtkIconEntryPosition; - -typedef struct _GtkIconEntry GtkIconEntry; -typedef struct _GtkIconEntryClass GtkIconEntryClass; -typedef struct _GtkIconEntryPrivate GtkIconEntryPrivate; - -struct _GtkIconEntry -{ - GtkEntry parent_object; - - GtkIconEntryPrivate* priv; -}; - -struct _GtkIconEntryClass -{ - GtkEntryClass parent_class; - - /* Signals */ - void (*icon_pressed) (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - int button); - void (*icon_released) (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - int button); - - void (*gtk_reserved1) (void); - void (*gtk_reserved2) (void); - void (*gtk_reserved3) (void); - void (*gtk_reserved4) (void); -}; - -GType gtk_icon_entry_get_type (void) G_GNUC_CONST; - -GtkWidget* gtk_icon_entry_new (void); - -void gtk_icon_entry_set_icon_from_pixbuf (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - GdkPixbuf *pixbuf); -void gtk_icon_entry_set_icon_from_stock (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - const gchar *stock_id); -void gtk_icon_entry_set_icon_from_icon_name (GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - const gchar *icon_name); - -void gtk_icon_entry_set_icon_from_gicon (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - GIcon *icon); - -GdkPixbuf* gtk_icon_entry_get_pixbuf (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos); - -GIcon* gtk_icon_entry_get_gicon (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos); - -void gtk_icon_entry_set_icon_highlight (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos, - gboolean highlight); - -gboolean gtk_icon_entry_get_icon_highlight (const GtkIconEntry *entry, - GtkIconEntryPosition icon_pos); - -void gtk_icon_entry_set_cursor (const GtkIconEntry *icon_entry, - GtkIconEntryPosition icon_pos, - GdkCursorType cursor_type); - -const gchar* gtk_icon_entry_get_tooltip (const GtkIconEntry *icon_entry, - GtkIconEntryPosition icon_pos); -void gtk_icon_entry_set_tooltip (const GtkIconEntry *icon_entry, - GtkIconEntryPosition icon_pos, - const gchar *text); - -void gtk_icon_entry_set_icon_sensitive (const GtkIconEntry *icon_entry, - GtkIconEntryPosition icon_pos, - gboolean sensitive); - -void gtk_icon_entry_set_progress_fraction (GtkIconEntry *icon_entry, - gdouble fraction); - -#endif G_END_DECLS diff --git a/midori/midori-browser.c b/midori/midori-browser.c index da96043e..a7579c09 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2658,11 +2658,7 @@ _action_compact_add_activate (GtkAction* action, g_free (label); gtk_widget_set_name (button, "GtkButton-thumb"); gtk_box_pack_start (box, button, TRUE, TRUE, 4); - #if GTK_CHECK_VERSION (2, 16, 0) gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action); - #else - gtk_action_connect_proxy (action, button); - #endif g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), dialog); } diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 1c509ca0..c615fb72 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -1342,13 +1342,8 @@ midori_location_action_icon_released_cb (GtkWidget* widget, content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); #endif hbox = gtk_hbox_new (FALSE, 0); - #if GTK_CHECK_VERSION (2, 16, 0) gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_gicon ( gtk_entry_get_icon_gicon (GTK_ENTRY (widget), icon_pos), GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0); - #else - gtk_box_pack_start (GTK_BOX (hbox), - gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0); - #endif gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (gtk_icon_entry_get_tooltip (GTK_ICON_ENTRY (widget), icon_pos)), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0); @@ -1920,36 +1915,24 @@ midori_location_action_set_security_hint (MidoriLocationAction* location_action, if (hint == MIDORI_SECURITY_UNKNOWN) { - #if GTK_CHECK_VERSION (2, 16, 0) gchar* icon_names[] = { "channel-insecure-symbolic", "lock-insecure", "dialog-information", NULL }; gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, g_themed_icon_new_from_names (icon_names, -1)); - #else - gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_INFO); - #endif gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, _("Not verified")); } else if (hint == MIDORI_SECURITY_TRUSTED) { - #if GTK_CHECK_VERSION (2, 16, 0) gchar* icon_names[] = { "channel-secure-symbolic", "lock-secure", "locked", NULL }; gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, g_themed_icon_new_from_names (icon_names, -1)); - #else - gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION); - #endif gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, _("Verified and encrypted connection")); } else if (hint == MIDORI_SECURITY_NONE) { - #if GTK_CHECK_VERSION (2, 16, 0) gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, g_themed_icon_new_with_default_fallbacks ("text-html-symbolic")); - #else - gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, STOCK_URL); - #endif gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, _("Open, unencrypted connection")); } diff --git a/midori/midori-view.c b/midori/midori-view.c index 16acf824..71c44a5f 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -3038,10 +3038,8 @@ webkit_web_view_download_requested_cb (GtkWidget* web_view, WebKitWebDataSource* datasource; WebKitNetworkRequest* request; GString* details; - #if GTK_CHECK_VERSION (2, 14, 0) GIcon* icon; GtkWidget* image; - #endif gchar* title; GdkScreen* screen; GtkIconTheme* icon_theme; @@ -3064,14 +3062,12 @@ webkit_web_view_download_requested_cb (GtkWidget* web_view, content_type = g_content_type_from_mime_type ("application/octet-stream"); mime_type = g_content_type_get_mime_type (content_type); description = g_content_type_get_description (content_type); - #if GTK_CHECK_VERSION (2, 14, 0) icon = g_content_type_get_icon (content_type); g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html"); image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG); g_object_unref (icon); gtk_widget_show (image); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); - #endif g_free (content_type); details = g_string_sized_new (20 * 4); diff --git a/midori/sokoke.c b/midori/sokoke.c index 2dfc6e11..ce3ea4ca 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -197,7 +197,6 @@ sokoke_show_uri_with_mime_type (GdkScreen* screen, !g_str_has_prefix (uri, "file://")); g_free (content_type); files = g_list_prepend (NULL, file); - #if GTK_CHECK_VERSION (2, 14, 0) #if GTK_CHECK_VERSION (3, 0, 0) context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen)); #else @@ -205,9 +204,6 @@ sokoke_show_uri_with_mime_type (GdkScreen* screen, #endif gdk_app_launch_context_set_screen (context, screen); gdk_app_launch_context_set_timestamp (context, timestamp); - #else - context = g_app_launch_context_new (); - #endif success = g_app_info_launch (app_info, files, context, error); @@ -314,13 +310,8 @@ sokoke_show_uri (GdkScreen* screen, sokoke_recursive_fork_protection (uri, TRUE); - #if GTK_CHECK_VERSION (2, 14, 0) if (gtk_show_uri (screen, uri, timestamp, error)) return TRUE; - #else - if (g_app_info_launch_default_for_uri (uri, NULL, NULL)) - return TRUE; - #endif #if !GLIB_CHECK_VERSION (2, 28, 0) info = sokoke_default_for_uri (uri, &scheme); diff --git a/toolbars/midori-findbar.c b/toolbars/midori-findbar.c index 89a5d342..6e5435fe 100644 --- a/toolbars/midori-findbar.c +++ b/toolbars/midori-findbar.c @@ -52,15 +52,10 @@ midori_findbar_set_icon (MidoriFindbar* findbar, { if (icon_name != NULL) { - #if GTK_CHECK_VERSION (2, 16, 0) gchar* symbolic_icon_name = g_strconcat (icon_name, "-symbolic", NULL); gtk_entry_set_icon_from_gicon (GTK_ENTRY (findbar->find_text), icon_pos, g_themed_icon_new_with_default_fallbacks (symbolic_icon_name)); g_free (symbolic_icon_name); - #else - gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (findbar->find_text), - icon_pos, icon_name); - #endif } else gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (findbar->find_text), diff --git a/wscript b/wscript index 45d46f22..1623b3c8 100644 --- a/wscript +++ b/wscript @@ -259,7 +259,7 @@ def configure (conf): check_pkg ('javascriptcoregtk-3.0', '1.5.1', args=args) conf.env.append_value ('VALAFLAGS', '-D HAVE_GTK3') else: - check_pkg ('gtk+-2.0', '2.10.0', var='GTK') + check_pkg ('gtk+-2.0', '2.16.0', var='GTK') check_pkg ('webkit-1.0', '1.1.17', args=args) if check_version (conf.check_cfg (modversion='webkit-1.0'), 1, 5, 1): check_pkg ('javascriptcoregtk-1.0', '1.5.1', args=args) -- 2.39.5