yelp r3036 - in trunk: . src
- From: dscorgie svn gnome org
- To: svn-commits-list gnome org
- Subject: yelp r3036 - in trunk: . src
- Date: Sun, 13 Jan 2008 19:32:10 +0000 (GMT)
Author: dscorgie
Date: Sun Jan 13 19:32:10 2008
New Revision: 3036
URL: http://svn.gnome.org/viewvc/yelp?rev=3036&view=rev
Log:
* src/gtkentryaction.c:
* src/gtkentryaction.h:
* src/yelp-window.c:
Make / activate find
Make find go away when losing focus (like epiphany)
Modified:
trunk/ChangeLog
trunk/src/gtkentryaction.c
trunk/src/gtkentryaction.h
trunk/src/yelp-window.c
Modified: trunk/src/gtkentryaction.c
==============================================================================
--- trunk/src/gtkentryaction.c (original)
+++ trunk/src/gtkentryaction.c Sun Jan 13 19:32:10 2008
@@ -34,6 +34,7 @@
{
char *text;
gboolean editable;
+ GtkWidget *entry_widget;
};
static void gtk_entry_action_init (GtkEntryAction *action);
@@ -85,11 +86,13 @@
GtkWidget *entry;
GtkWidget *box;
GtkWidget *label;
+ GtkEntryAction *action_cast = (GtkEntryAction *)action;
tool_item = gtk_tool_item_new ();
box = gtk_hbox_new (FALSE, 6);
label = gtk_label_new ("");
entry = gtk_entry_new ();
+ action_cast->priv->entry_widget = entry;
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
gtk_container_add (GTK_CONTAINER (tool_item), box);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
@@ -346,3 +349,12 @@
g_free (old_text);
g_object_notify (G_OBJECT (action), "text");
}
+
+gboolean
+gtk_entry_action_has_focus (GtkEntryAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ENTRY_ACTION (action), FALSE);
+
+ return (GTK_WIDGET_HAS_FOCUS (action->priv->entry_widget));
+
+}
Modified: trunk/src/gtkentryaction.h
==============================================================================
--- trunk/src/gtkentryaction.h (original)
+++ trunk/src/gtkentryaction.h Sun Jan 13 19:32:10 2008
@@ -61,6 +61,7 @@
void gtk_entry_action_set_text (GtkEntryAction *action,
const char *text);
+gboolean gtk_entry_action_has_focus (GtkEntryAction *action);
G_END_DECLS
#endif
Modified: trunk/src/yelp-window.c
==============================================================================
--- trunk/src/yelp-window.c (original)
+++ trunk/src/yelp-window.c Sun Jan 13 19:32:10 2008
@@ -131,7 +131,9 @@
static void html_popupmenu_requested_cb (YelpHtml *html,
gchar *uri,
gpointer user_data);
-
+static gboolean window_key_event_cb (GtkWidget *widget,
+ GdkEventKey *event,
+ YelpWindow *window);
/** GtkTreeView Callbacks **/
static void tree_selection_changed_cb (GtkTreeSelection *selection,
YelpWindow *window);
@@ -209,6 +211,9 @@
gboolean next);
static void window_find_clicked_cb (GtkWidget *button,
YelpWindow *window);
+static gboolean window_find_hide_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ YelpWindow *window);
static void window_find_next_cb (GtkAction *action,
YelpWindow *window);
static void window_find_previous_cb (GtkAction *action,
@@ -238,6 +243,7 @@
GtkWidget *find_entry;
YelpHtml *html_view;
GtkWidget *side_sw;
+ GtkWidget *search_action;
/* Find in Page */
GtkToolItem *find_prev;
@@ -1242,13 +1248,13 @@
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (f_proxy),
priv->forward_menu);
- action = gtk_entry_action_new ("Search",
+ priv->search_action = gtk_entry_action_new ("Search",
_("_Search:"),
_("Search for other documentation"),
NULL);
- g_signal_connect (G_OBJECT (action), "activate",
+ g_signal_connect (G_OBJECT (priv->search_action), "activate",
G_CALLBACK (search_activated), window);
- gtk_action_group_add_action (priv->action_group, action);
+ gtk_action_group_add_action (priv->action_group, priv->search_action);
priv->ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (priv->ui_manager, priv->action_group, 0);
@@ -1285,6 +1291,8 @@
toolbar = gtk_ui_manager_get_widget(priv->ui_manager, "ui/tools");
+ printf ("SE is %p\n", priv->search_action);
+
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (f_proxy), 0);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (b_proxy), 0);
@@ -1373,6 +1381,11 @@
"popupmenu_requested",
G_CALLBACK (html_popupmenu_requested_cb),
window);
+ /* Connect to look for /'s */
+ g_signal_connect (window,
+ "key-press-event",
+ G_CALLBACK (window_key_event_cb),
+ window);
gtk_box_pack_end (GTK_BOX (priv->html_pane),
GTK_WIDGET (priv->html_view),
TRUE, TRUE, 0);
@@ -1391,8 +1404,41 @@
GTK_WIDGET (priv->html_view));
}
+static gboolean
+window_key_event_cb (GtkWidget *widget, GdkEventKey *event,
+ YelpWindow *window)
+{
+ if ((window->priv->search_action &&
+ gtk_entry_action_has_focus (window->priv->search_action)) ||
+ GTK_WIDGET_HAS_FOCUS (window->priv->find_entry))
+ return FALSE;
+
+ if (event->keyval == GDK_slash) {
+ window_find_cb (NULL, window);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+window_find_hide_cb (GtkWidget *widget, GdkEventFocus *event,
+ YelpWindow *window)
+{
+ YelpWindowPriv *priv;
+
+ g_return_if_fail (YELP_IS_WINDOW (window));
+
+ priv = window->priv;
+
+ gtk_widget_hide ((GtkWidget *) priv->find_bar);
+ return FALSE;
+}
+
+
static void
-window_populate_find (YelpWindow *window, GtkWidget *find_bar)
+window_populate_find (YelpWindow *window,
+ GtkWidget *find_bar)
{
GtkWidget *box;
GtkWidget *label;
@@ -1413,6 +1459,8 @@
G_CALLBACK (window_find_entry_activate_cb), window);
g_signal_connect (G_OBJECT (priv->find_entry), "key-press-event",
G_CALLBACK (window_find_entry_key_pressed_cb), window);
+ g_signal_connect (G_OBJECT (priv->find_entry), "focus-out-event",
+ G_CALLBACK (window_find_hide_cb), window);
gtk_box_pack_start (GTK_BOX (box), priv->find_entry, TRUE, TRUE, 0);
item = gtk_tool_item_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]