aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog26
-rw-r--r--lib/egg/egg-action.c16
-rw-r--r--lib/egg/eggtoggletoolbutton.c26
-rw-r--r--lib/egg/eggtoolbar.c74
-rw-r--r--lib/egg/eggtoolbutton.c46
-rw-r--r--lib/egg/eggtoolbutton.h2
-rw-r--r--lib/egg/eggtoolitem.c55
-rw-r--r--lib/widgets/ephy-location-entry.c120
-rw-r--r--lib/widgets/ephy-location-entry.h13
-rw-r--r--src/ephy-location-action.c28
-rwxr-xr-xsrc/toolbar.c1
11 files changed, 245 insertions, 162 deletions
diff --git a/ChangeLog b/ChangeLog
index 81a0cb772..bb65e94da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2003-07-01 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/widgets/ephy-location-entry.h:
+ * lib/widgets/ephy-location-entry.c: (ephy_location_entry_set_tooltip),
+ (ephy_location_entry_construct_contents),
+ (ephy_location_entry_class_init), (ephy_location_entry_init),
+ (ephy_location_entry_finalize):
+
+ Make the location entry an EggToolItem, and provide a custom
+ tooptip setter. Fix mem leak.
+
+ * src/ephy-location-action.c: (create_tool_item),
+ (ephy_location_action_class_init), (connect_proxy):
+
+ Use the location entry EggToolItem instead of constructing it
+ explicitly.
+
+ * src/toolbar.c: (toolbar_setup_action):
+
+ Set tooltip for location entry.
+
+ * lib/egg/egg-action.c: (connect_proxy), (disconnect_proxy):
+
+ Connect the tooltip sync'er on any EggToolItem, not just EggTollButton:s.
+ Disconnect the tooltip sync func on disconnect, too.
+
2003-07-01 David Bordoley <bordoley@msu.edu>
* src/ephy-window.c: (setup_window):
diff --git a/lib/egg/egg-action.c b/lib/egg/egg-action.c
index aba6d59db..054159f45 100644
--- a/lib/egg/egg-action.c
+++ b/lib/egg/egg-action.c
@@ -549,10 +549,6 @@ connect_proxy (EggAction *action, GtkWidget *proxy)
g_signal_connect_object (action, "notify::short_label",
G_CALLBACK (egg_action_sync_short_label),
proxy, 0);
- egg_action_sync_tooltip (action, NULL, proxy);
- g_signal_connect_object (action, "notify::tooltip",
- G_CALLBACK (egg_action_sync_tooltip),
- proxy, 0);
g_object_set (G_OBJECT (proxy), "stock_id", action->stock_id, NULL);
g_signal_connect_object (action, "notify::stock_id",
@@ -566,6 +562,14 @@ connect_proxy (EggAction *action, GtkWidget *proxy)
G_CALLBACK (egg_action_activate), action,
G_CONNECT_SWAPPED);
}
+
+ if (EGG_IS_TOOL_ITEM (proxy))
+ {
+ egg_action_sync_tooltip (action, NULL, proxy);
+ g_signal_connect_object (action, "notify::tooltip",
+ G_CALLBACK (egg_action_sync_tooltip),
+ proxy, 0);
+ }
}
static void
@@ -597,6 +601,10 @@ disconnect_proxy (EggAction *action, GtkWidget *proxy)
g_signal_handlers_disconnect_by_func (action,
G_CALLBACK (egg_action_sync_stock_id), proxy);
+ g_signal_handlers_disconnect_by_func (proxy,
+ G_CALLBACK (egg_action_sync_tooltip),
+ action);
+
/* menu item specific synchronisers ... */
g_signal_handlers_disconnect_by_func (action,
G_CALLBACK (egg_action_sync_label),
diff --git a/lib/egg/eggtoggletoolbutton.c b/lib/egg/eggtoggletoolbutton.c
index b755275f2..75d511709 100644
--- a/lib/egg/eggtoggletoolbutton.c
+++ b/lib/egg/eggtoggletoolbutton.c
@@ -38,7 +38,6 @@ enum {
static void egg_toggle_tool_button_init (EggToggleToolButton *button);
static void egg_toggle_tool_button_class_init (EggToggleToolButtonClass *klass);
-static void egg_toggle_tool_button_finalize (GObject *object);
static gboolean egg_toggle_tool_button_create_menu_proxy (EggToolItem *button);
@@ -90,7 +89,6 @@ egg_toggle_tool_button_class_init (EggToggleToolButtonClass *klass)
toolitem_class = (EggToolItemClass *)klass;
toolbutton_class = (EggToolButtonClass *)klass;
- object_class->finalize = egg_toggle_tool_button_finalize;
toolitem_class->create_menu_proxy = egg_toggle_tool_button_create_menu_proxy;
toolbutton_class->button_type = GTK_TYPE_TOGGLE_BUTTON;
@@ -111,18 +109,6 @@ egg_toggle_tool_button_init (EggToggleToolButton *button)
G_CALLBACK (button_toggled), button, 0);
}
-static void
-egg_toggle_tool_button_finalize (GObject *object)
-{
- EggToggleToolButton *button = EGG_TOGGLE_TOOL_BUTTON (object);
-
- if (button->menu_item)
- g_object_remove_weak_pointer (G_OBJECT (button->menu_item),
- (gpointer *)&(button->menu_item));
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
static gboolean
egg_toggle_tool_button_create_menu_proxy (EggToolItem *item)
{
@@ -162,6 +148,18 @@ egg_toggle_tool_button_create_menu_proxy (EggToolItem *item)
return TRUE;
}
+/* There are two activatable widgets, a toggle button and a menu item.
+ *
+ * If a widget is activated and the state of the tool button is the same as
+ * the new state of the activated widget, then the other widget was the one
+ * that was activated by the user and updated the tool button's state.
+ *
+ * If the state of the tool button is not the same as the new state of the
+ * activated widget, then the activation was activated by the user, and the
+ * widget needs to make sure the tool button is updated before the other
+ * widget is activated. This will make sure the other widget a tool button
+ * in a state that matches its own new state.
+ */
static void
menu_item_activated (GtkWidget *menu_item,
EggToggleToolButton *toggle_tool_button)
diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c
index 7f81ed677..ed4189aae 100644
--- a/lib/egg/eggtoolbar.c
+++ b/lib/egg/eggtoolbar.c
@@ -151,9 +151,8 @@ static gboolean egg_toolbar_move_focus (EggToolbar *toolbar,
static gboolean egg_toolbar_focus_ends (EggToolbar *toolbar,
gboolean home);
-static gboolean egg_toolbar_button_press (GtkWidget *button,
- GdkEventButton *event,
- EggToolbar *toolbar);
+static gboolean egg_toolbar_button_press (GtkWidget *toolbar,
+ GdkEventButton *event);
static gboolean egg_toolbar_arrow_button_press (GtkWidget *button,
GdkEventButton *event,
EggToolbar *toolbar);
@@ -285,6 +284,7 @@ egg_toolbar_class_init (EggToolbarClass *klass)
gobject_class->set_property = egg_toolbar_set_property;
gobject_class->get_property = egg_toolbar_get_property;
+ widget_class->button_press_event = egg_toolbar_button_press;
widget_class->expose_event = egg_toolbar_expose;
widget_class->size_request = egg_toolbar_size_request;
widget_class->size_allocate = egg_toolbar_size_allocate;
@@ -527,9 +527,6 @@ egg_toolbar_init (EggToolbar *toolbar)
gtk_widget_set_parent (priv->arrow_button, GTK_WIDGET (toolbar));
- g_signal_connect (GTK_WIDGET (toolbar), "button_press_event",
- G_CALLBACK (egg_toolbar_button_press), toolbar);
-
/* which child position a drop will occur at */
priv->drop_index = -1;
priv->drag_highlight = NULL;
@@ -878,9 +875,14 @@ egg_toolbar_size_request (GtkWidget *widget,
gtk_widget_size_request (priv->arrow_button, &arrow_requisition);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- long_req = pack_end_size + MIN (pack_front_size, arrow_requisition.width);
+ long_req = arrow_requisition.width;
else
- long_req = pack_end_size + MIN (pack_front_size, arrow_requisition.height);
+ long_req = arrow_requisition.height;
+
+ /* There is no point requesting space for the arrow if that would take
+ * up more space than all the items combined
+ */
+ long_req = MIN (long_req, pack_front_size + pack_end_size);
}
else
{
@@ -1305,16 +1307,19 @@ egg_toolbar_focus_ends (EggToolbar *toolbar,
gboolean home)
{
GList *children, *list;
- GtkTextDirection direction = gtk_widget_get_direction (GTK_WIDGET (toolbar));
+ GtkDirectionType dir = home? GTK_DIR_RIGHT : GTK_DIR_LEFT;
- if (direction == GTK_TEXT_DIR_RTL)
- children = egg_toolbar_list_children_in_focus_order (toolbar, GTK_DIR_RIGHT);
- else
- children = egg_toolbar_list_children_in_focus_order (toolbar, GTK_DIR_LEFT);
+ children = egg_toolbar_list_children_in_focus_order (toolbar, dir);
+
+ if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
+ {
+ children = g_list_reverse (children);
+ if (dir == GTK_DIR_RIGHT)
+ dir = GTK_DIR_LEFT;
+ else
+ dir = GTK_DIR_RIGHT;
+ }
- if (home)
- children = g_list_reverse (children);
-
for (list = children; list != NULL; list = list->next)
{
GtkWidget *child = list->data;
@@ -1322,7 +1327,7 @@ egg_toolbar_focus_ends (EggToolbar *toolbar,
if (GTK_CONTAINER (toolbar)->focus_child == child)
break;
- if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, GTK_DIR_RIGHT))
+ if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
break;
}
@@ -1355,14 +1360,21 @@ egg_toolbar_move_focus (EggToolbar *toolbar,
return TRUE;
}
+/* The focus handler for the toolbar. It called when the user presses TAB or otherwise
+ * tries to focus the toolbar.
+ */
static gboolean
egg_toolbar_focus (GtkWidget *widget,
GtkDirectionType dir)
{
EggToolbar *toolbar = EGG_TOOLBAR (widget);
GList *children, *list;
- gboolean retval = FALSE;
-
+
+ /* if focus is already somewhere inside the toolbar then return FALSE.
+ * The only way focus can stay inside the toolbar is when the user presses
+ * arrow keys or Ctrl TAB (both of which are handled by the
+ * egg_toolbar_move_focus() keybinding function.
+ */
if (GTK_CONTAINER (widget)->focus_child)
return FALSE;
@@ -1372,16 +1384,13 @@ egg_toolbar_focus (GtkWidget *widget,
{
GtkWidget *child = list->data;
- if (GTK_WIDGET_MAPPED (child))
- {
- retval = gtk_widget_child_focus (child, dir);
- break;
- }
+ if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
+ return TRUE;
}
g_list_free (children);
- return retval;
+ return FALSE;
}
static void
@@ -1927,7 +1936,8 @@ egg_toolbar_arrow_button_clicked (GtkWidget *button,
(!priv->menu || !GTK_WIDGET_VISIBLE (GTK_WIDGET (priv->menu))))
{
/* We only get here when the button is clicked with the keybaord,
- * because mouse button presses result in the menu being shown.
+ * because mouse button presses result in the menu being shown so
+ * that priv->menu would be non-NULL and visible.
*/
show_menu (toolbar, NULL);
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
@@ -1946,15 +1956,11 @@ egg_toolbar_arrow_button_press (GtkWidget *button,
}
static gboolean
-egg_toolbar_button_press (GtkWidget *button,
- GdkEventButton *event,
- EggToolbar *toolbar)
+egg_toolbar_button_press (GtkWidget *toolbar,
+ GdkEventButton *event)
{
if (event->button == 3)
- {
- g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0, NULL);
- return FALSE;
- }
+ g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0, NULL);
return FALSE;
}
@@ -2164,6 +2170,8 @@ egg_toolbar_set_style (EggToolbar *toolbar,
toolbar->style_set = TRUE;
g_signal_emit (toolbar, toolbar_signals[STYLE_CHANGED], 0, style);
+
+
}
GtkToolbarStyle
diff --git a/lib/egg/eggtoolbutton.c b/lib/egg/eggtoolbutton.c
index 88b70e632..6f827e576 100644
--- a/lib/egg/eggtoolbutton.c
+++ b/lib/egg/eggtoolbutton.c
@@ -211,8 +211,15 @@ egg_tool_button_size_request (GtkWidget *widget,
{
GtkWidget *child = GTK_BIN (widget)->child;
- if (child)
- gtk_widget_size_request (child, requisition);
+ if (child && GTK_WIDGET_VISIBLE (child))
+ {
+ gtk_widget_size_request (child, requisition);
+ }
+ else
+ {
+ requisition->width = 0;
+ requisition->height = 0;
+ }
requisition->width += GTK_CONTAINER (widget)->border_width * 2;
requisition->height += GTK_CONTAINER (widget)->border_width * 2;
@@ -617,19 +624,19 @@ void
egg_tool_button_set_label (EggToolButton *button,
const gchar *label)
{
+ gchar *old_label;
+
g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
- if (label != button->label_text)
- {
- if (button->label_text)
- g_free (button->label_text);
-
- button->label_text = g_strdup (label);
+ old_label = button->label_text;
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
+ button->label_text = g_strdup (label);
+ egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
- g_object_notify (G_OBJECT (button), "label");
- }
+ g_object_notify (G_OBJECT (button), "label");
+
+ if (old_label)
+ g_free (old_label);
}
G_CONST_RETURN gchar *
@@ -670,19 +677,18 @@ void
egg_tool_button_set_stock_id (EggToolButton *button,
const gchar *stock_id)
{
+ gchar *old_stock_id;
+
g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
- if (button->stock_id != stock_id)
- {
- if (button->stock_id)
- g_free (button->stock_id);
+ old_stock_id = button->stock_id;
- button->stock_id = g_strdup (stock_id);
-
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
+ button->stock_id = g_strdup (stock_id);
+ egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
+
+ g_object_notify (G_OBJECT (button), "stock_id");
- g_object_notify (G_OBJECT (button), "stock_id");
- }
+ g_free (old_stock_id);
}
G_CONST_RETURN gchar *
diff --git a/lib/egg/eggtoolbutton.h b/lib/egg/eggtoolbutton.h
index 4ee7ff157..667d6547c 100644
--- a/lib/egg/eggtoolbutton.h
+++ b/lib/egg/eggtoolbutton.h
@@ -78,8 +78,6 @@ G_CONST_RETURN gchar *egg_tool_button_get_stock_id (EggToolButton *button);
void egg_tool_button_set_icon_set (EggToolButton *button,
GtkIconSet *icon_set);
GtkIconSet * egg_tool_button_get_icon_set (EggToolButton *button);
-void egg_tool_button_set_icon_set (EggToolButton *button,
- GtkIconSet *icon_set);
void egg_tool_button_set_icon_widget (EggToolButton *button,
GtkWidget *icon);
GtkWidget * egg_tool_button_get_icon_widget (EggToolButton *button);
diff --git a/lib/egg/eggtoolitem.c b/lib/egg/eggtoolitem.c
index 0e7ea5b72..b66376d36 100644
--- a/lib/egg/eggtoolitem.c
+++ b/lib/egg/eggtoolitem.c
@@ -362,8 +362,15 @@ egg_tool_item_size_request (GtkWidget *widget,
gint xthickness = widget->style->xthickness;
gint ythickness = widget->style->ythickness;
- if (child)
- gtk_widget_size_request (child, requisition);
+ if (child && GTK_WIDGET_VISIBLE (child))
+ {
+ gtk_widget_size_request (child, requisition);
+ }
+ else
+ {
+ requisition->height = 0;
+ requisition->width = 0;
+ }
requisition->width += (xthickness + GTK_CONTAINER (widget)->border_width) * 2;
requisition->height += (ythickness + GTK_CONTAINER (widget)->border_width) * 2;
@@ -405,14 +412,18 @@ egg_tool_item_size_allocate (GtkWidget *widget,
static gboolean
egg_tool_item_create_menu_proxy (EggToolItem *item)
{
- GtkWidget *menu_item = NULL;
-
if (!GTK_BIN (item)->child)
- menu_item = gtk_separator_menu_item_new();
+ {
+ GtkWidget *menu_item = NULL;
+
+ menu_item = gtk_separator_menu_item_new();
+
+ egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
- egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
+ return TRUE;
+ }
- return TRUE;
+ return FALSE;
}
EggToolItem *
@@ -543,9 +554,12 @@ egg_tool_item_real_set_tooltip (EggToolItem *tool_item,
const gchar *tip_text,
const gchar *tip_private)
{
- GtkBin *bin = GTK_BIN (tool_item);
+ GtkWidget *child = GTK_BIN (tool_item)->child;
- gtk_tooltips_set_tip (tooltips, bin->child, tip_text, tip_private);
+ if (!child)
+ return FALSE;
+
+ gtk_tooltips_set_tip (tooltips, child, tip_text, tip_private);
return TRUE;
}
@@ -678,19 +692,22 @@ egg_tool_item_set_proxy_menu_item (EggToolItem *tool_item,
g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
g_return_if_fail (menu_item_id != NULL);
- if (tool_item->menu_item)
- g_object_unref (G_OBJECT (tool_item->menu_item));
-
if (tool_item->menu_item_id)
g_free (tool_item->menu_item_id);
+
+ tool_item->menu_item_id = g_strdup (menu_item_id);
- if (menu_item)
+ if (tool_item->menu_item != menu_item)
{
- g_object_ref (menu_item);
- gtk_object_sink (GTK_OBJECT (menu_item));
+ if (tool_item->menu_item)
+ g_object_unref (G_OBJECT (tool_item->menu_item));
+
+ if (menu_item)
+ {
+ g_object_ref (menu_item);
+ gtk_object_sink (GTK_OBJECT (menu_item));
+ }
+
+ tool_item->menu_item = menu_item;
}
-
- tool_item->menu_item = menu_item;
-
- tool_item->menu_item_id = g_strdup (menu_item_id);
}
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 6243305c8..076d8642f 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2002 Ricardo Fernández Pascual
+ * Copyright (C) 2003 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,10 +24,13 @@
#include "ephy-prefs.h"
#include "ephy-debug.h"
+#include <glib-object.h>
+#include <gtk/gtkhbox.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkwindow.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkmain.h>
+#include <gtk/gtktooltips.h>
#include <libgnomeui/gnome-entry.h>
#include <string.h>
@@ -36,7 +40,7 @@
struct _EphyLocationEntryPrivate {
GtkWidget *combo;
GtkWidget *entry;
- gchar *before_completion;
+ char *before_completion;
EphyAutocompletion *autocompletion;
EphyAutocompletionWindow *autocompletion_window;
gboolean autocompletion_window_visible;
@@ -46,8 +50,7 @@ struct _EphyLocationEntryPrivate {
gboolean going_to_site;
gboolean user_changed;
- gchar *autocompletion_key;
- gchar *last_completion;
+ char *autocompletion_key;
char *last_action_target;
};
@@ -57,32 +60,34 @@ struct _EphyLocationEntryPrivate {
/**
* Private functions, only availble from this file
*/
-static void ephy_location_entry_class_init (EphyLocationEntryClass *klass);
-static void ephy_location_entry_init (EphyLocationEntry *w);
-static void ephy_location_entry_finalize_impl (GObject *o);
-static void ephy_location_entry_build (EphyLocationEntry *w);
-static gboolean ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event,
- EphyLocationEntry *w);
-static void ephy_location_entry_activate_cb (GtkEntry *entry,
- EphyLocationEntry *w);
-static void ephy_location_entry_autocompletion_sources_changed_cb (EphyAutocompletion *aw,
- EphyLocationEntry *w);
-static gint ephy_location_entry_autocompletion_show_alternatives_to (EphyLocationEntry *w);
-static void ephy_location_entry_autocompletion_window_url_activated_cb
-/***/ (EphyAutocompletionWindow *aw,
- const gchar *target,
- int action,
- EphyLocationEntry *w);
-static void ephy_location_entry_list_event_after_cb (GtkWidget *list,
- GdkEvent *event,
- EphyLocationEntry *e);
-static void ephy_location_entry_editable_changed_cb (GtkEditable *editable,
- EphyLocationEntry *e);
-static void ephy_location_entry_set_autocompletion_key (EphyLocationEntry *e);
-static void ephy_location_entry_autocompletion_show_alternatives (EphyLocationEntry *w);
-static void ephy_location_entry_autocompletion_hide_alternatives (EphyLocationEntry *w);
-static void ephy_location_entry_autocompletion_window_hidden_cb (EphyAutocompletionWindow *aw,
- EphyLocationEntry *w);
+static void ephy_location_entry_class_init (EphyLocationEntryClass *klass);
+static void ephy_location_entry_init (EphyLocationEntry *w);
+static void ephy_location_entry_finalize_impl (GObject *o);
+static void ephy_location_entry_construct_contents (EphyLocationEntry *w);
+static gboolean ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event,
+ EphyLocationEntry *w);
+static void ephy_location_entry_activate_cb (GtkEntry *entry,
+ EphyLocationEntry *w);
+static void ephy_location_entry_autocompletion_sources_changed_cb
+ (EphyAutocompletion *aw,
+ EphyLocationEntry *w);
+static gint ephy_location_entry_autocompletion_show_alternatives_to (EphyLocationEntry *w);
+static void ephy_location_entry_autocompletion_window_url_activated_cb
+ (EphyAutocompletionWindow *aw,
+ const gchar *target,
+ int action,
+ EphyLocationEntry *w);
+static void ephy_location_entry_list_event_after_cb (GtkWidget *list,
+ GdkEvent *event,
+ EphyLocationEntry *e);
+static void ephy_location_entry_editable_changed_cb (GtkEditable *editable,
+ EphyLocationEntry *e);
+static void ephy_location_entry_set_autocompletion_key (EphyLocationEntry *e);
+static void ephy_location_entry_autocompletion_show_alternatives (EphyLocationEntry *w);
+static void ephy_location_entry_autocompletion_hide_alternatives (EphyLocationEntry *w);
+static void ephy_location_entry_autocompletion_window_hidden_cb
+ (EphyAutocompletionWindow *aw,
+ EphyLocationEntry *w);
static void
insert_text_cb (GtkWidget *editable,
char *new_text,
@@ -95,7 +100,7 @@ delete_text_cb (GtkWidget *editable,
int end_pos,
EphyLocationEntry *w);
-static gpointer gtk_hbox_class;
+static GObjectClass *parent_class = NULL;
/**
* Signals enums and ids
@@ -108,6 +113,8 @@ enum EphyLocationEntrySignalsEnum {
};
static gint EphyLocationEntrySignals[LAST_SIGNAL];
+#define MENU_ID "ephy-location-entry-menu-id"
+
GType
ephy_location_entry_get_type (void)
{
@@ -128,7 +135,7 @@ ephy_location_entry_get_type (void)
(GInstanceInitFunc) ephy_location_entry_init
};
- ephy_location_entry_type = g_type_register_static (GTK_TYPE_HBOX,
+ ephy_location_entry_type = g_type_register_static (EGG_TYPE_TOOL_ITEM,
"EphyLocationEntry",
&our_info, 0);
}
@@ -136,11 +143,32 @@ ephy_location_entry_get_type (void)
return ephy_location_entry_type;
}
+static gboolean
+ephy_location_entry_set_tooltip (EggToolItem *tool_item,
+ GtkTooltips *tooltips,
+ const char *tip_text,
+ const char *tip_private)
+{
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (tool_item);
+
+ g_return_val_if_fail (EPHY_IS_LOCATION_ENTRY (entry), FALSE);
+
+ gtk_tooltips_set_tip (tooltips, entry->priv->entry, tip_text, tip_private);
+
+ return TRUE;
+}
+
static void
ephy_location_entry_class_init (EphyLocationEntryClass *klass)
{
- G_OBJECT_CLASS (klass)->finalize = ephy_location_entry_finalize_impl;
- gtk_hbox_class = g_type_class_peek_parent (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ EggToolItemClass *tool_item_class = EGG_TOOL_ITEM_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ephy_location_entry_finalize_impl;
+
+ tool_item_class->set_tooltip = ephy_location_entry_set_tooltip;
EphyLocationEntrySignals[ACTIVATED] = g_signal_new (
"activated", G_OBJECT_CLASS_TYPE (klass),
@@ -183,13 +211,20 @@ location_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EphyLocationEntr
static void
ephy_location_entry_init (EphyLocationEntry *w)
{
- EphyLocationEntryPrivate *p = g_new0 (EphyLocationEntryPrivate, 1);
+ EphyLocationEntryPrivate *p;
+
+ LOG ("EphyLocationEntry initialising %p", w)
+
+ p = g_new0 (EphyLocationEntryPrivate, 1);
w->priv = p;
p->last_action_target = NULL;
p->before_completion = NULL;
p->user_changed = TRUE;
+ p->autocompletion_key = NULL;
+
+ ephy_location_entry_construct_contents (w);
- ephy_location_entry_build (w);
+ egg_tool_item_set_expand (EGG_TOOL_ITEM (w), TRUE);
g_signal_connect (w->priv->entry,
"focus_out_event",
@@ -218,9 +253,10 @@ ephy_location_entry_finalize_impl (GObject *o)
LOG ("EphyLocationEntry finalized")
g_free (p->before_completion);
+ g_free (p->autocompletion_key);
g_free (p);
- G_OBJECT_CLASS (gtk_hbox_class)->finalize (o);
+ G_OBJECT_CLASS (parent_class)->finalize (o);
}
GtkWidget *
@@ -242,15 +278,21 @@ ephy_location_entry_button_press_event_cb (GtkWidget *entry, GdkEventButton *eve
}
static void
-ephy_location_entry_build (EphyLocationEntry *w)
+ephy_location_entry_construct_contents (EphyLocationEntry *w)
{
EphyLocationEntryPrivate *p = w->priv;
- GtkWidget *list;
+ GtkWidget *hbox, *list;
+
+ LOG ("EphyLocationEntry constructing contents %p", w)
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (w), hbox);
+ gtk_widget_show (hbox);
p->combo = gnome_entry_new ("ephy-url-history");
p->entry = GTK_COMBO (p->combo)->entry;
gtk_widget_show (p->combo);
- gtk_box_pack_start (GTK_BOX (w), p->combo, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), p->combo, TRUE, TRUE, 0);
g_signal_connect (p->entry, "key-press-event",
G_CALLBACK (ephy_location_entry_key_press_event_cb), w);
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index 7191d918b..44dea2608 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2002 Ricardo Fernández Pascual
+ * Copyright (C) 2002 Ricardo Fernández Pascual
+ * Copyright (C) 2003 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,9 +20,7 @@
#ifndef EPHY_LOCATION_ENTRY_H
#define EPHY_LOCATION_ENTRY_H
-#include <glib-object.h>
-#include <gtk/gtkhbox.h>
-
+#include "eggtoolitem.h"
#include "ephy-autocompletion.h"
/* object forward declarations */
@@ -31,7 +30,7 @@ typedef struct _EphyLocationEntryClass EphyLocationEntryClass;
typedef struct _EphyLocationEntryPrivate EphyLocationEntryPrivate;
/**
- * EphyFolderTbWidget object
+ * EphyLocationEntry object
*/
#define EPHY_TYPE_LOCATION_ENTRY (ephy_location_entry_get_type())
@@ -46,7 +45,7 @@ typedef struct _EphyLocationEntryPrivate EphyLocationEntryPrivate;
struct _EphyLocationEntryClass
{
- GtkHBoxClass parent_class;
+ EggToolItemClass parent_class;
/* signals */
void (*activated) (EphyLocationEntry *w,
@@ -61,7 +60,7 @@ struct _EphyLocationEntryClass
/* Remember: fields are public read-only */
struct _EphyLocationEntry
{
- GtkHBox parent_object;
+ EggToolItem parent_object;
EphyLocationEntryPrivate *priv;
};
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index 67ac05be3..d8d62b82e 100644
--- a/src/ephy-location-action.c
+++ b/src/ephy-location-action.c
@@ -20,7 +20,6 @@
#include "ephy-location-entry.h"
#include "ephy-shell.h"
#include "ephy-debug.h"
-#include "eggtoolitem.h"
static void ephy_location_action_init (EphyLocationAction *action);
static void ephy_location_action_class_init (EphyLocationActionClass *class);
@@ -62,25 +61,6 @@ ephy_location_action_get_type (void)
return type;
}
-static GtkWidget *
-create_tool_item (EggAction *action)
-{
- GtkWidget *item;
- GtkWidget *location;
-
- LOG ("Create location toolitem")
-
- item = GTK_WIDGET (egg_tool_item_new ());
- location = ephy_location_entry_new ();
- gtk_container_add (GTK_CONTAINER (item), location);
- egg_tool_item_set_expand (EGG_TOOL_ITEM (item), TRUE);
- gtk_widget_show (location);
-
- LOG ("Create location toolitem: Done.")
-
- return item;
-}
-
static void
location_url_activate_cb (EphyLocationEntry *entry,
const char *content,
@@ -119,11 +99,12 @@ static void
connect_proxy (EggAction *action, GtkWidget *proxy)
{
EphyAutocompletion *ac = ephy_shell_get_autocompletion (ephy_shell);
- EphyLocationEntry *e;
+ EphyLocationEntry *e = EPHY_LOCATION_ENTRY (proxy);
LOG ("Connect location proxy")
- e = EPHY_LOCATION_ENTRY (GTK_BIN (proxy)->child);
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (e));
+
ephy_location_entry_set_autocompletion (e, ac);
g_signal_connect (e, "activated",
@@ -143,7 +124,6 @@ ephy_location_action_class_init (EphyLocationActionClass *class)
action_class = EGG_ACTION_CLASS (class);
action_class->toolbar_item_type = EPHY_TYPE_LOCATION_ENTRY;
- action_class->create_tool_item = create_tool_item;
action_class->connect_proxy = connect_proxy;
ephy_location_action_signals[GO_LOCATION] =
@@ -172,7 +152,7 @@ ephy_location_action_get_widget (EphyLocationAction *action)
if (slist)
{
- return GTK_BIN (slist->data)->child;
+ return GTK_WIDGET (slist->data);
}
else
{
diff --git a/src/toolbar.c b/src/toolbar.c
index da506f8c4..0a290d551 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -346,6 +346,7 @@ toolbar_setup_actions (Toolbar *t)
"name", "Location",
"label", _("Address Entry"),
"stock_id", EPHY_STOCK_ENTRY,
+ "tooltip", _("Enter a web address to open, or a phrase to search for on the web."),
NULL);
g_signal_connect (action, "go_location",
G_CALLBACK (go_location_cb), t->priv->window);