[gedit] Remove search bindings from the View and move the managing to GeditViewFrame.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Remove search bindings from the View and move the managing to GeditViewFrame.
- Date: Sun, 27 Feb 2011 18:55:03 +0000 (UTC)
commit 3caae05a66c282c2c37c582f299874d54b485dc5
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Feb 27 19:53:06 2011 +0100
Remove search bindings from the View and move the managing to GeditViewFrame.
gedit/gedit-commands-search.c | 51 ++++++++++++------------------
gedit/gedit-view-frame.c | 69 ++++++++++++++++++++++-------------------
gedit/gedit-view-frame.h | 6 +++
gedit/gedit-view.c | 58 ----------------------------------
gedit/gedit-view.h | 5 ---
5 files changed, 63 insertions(+), 126 deletions(-)
---
diff --git a/gedit/gedit-commands-search.c b/gedit/gedit-commands-search.c
index 04a433d..fc08b5c 100644
--- a/gedit/gedit-commands-search.c
+++ b/gedit/gedit-commands-search.c
@@ -555,24 +555,17 @@ void
_gedit_cmd_search_find (GtkAction *action,
GeditWindow *window)
{
- GeditView *active_view;
+ GeditTab *active_tab;
+ GeditViewFrame *frame;
gedit_debug (DEBUG_COMMANDS);
- active_view = gedit_window_get_active_view (window);
- if (active_view == NULL)
+ active_tab = gedit_window_get_active_tab (window);
+ if (active_tab == NULL)
return;
- /* Focus the view if needed: we need to focus the view otherwise
- activating the binding for goto line has no effect */
- gtk_widget_grab_focus (GTK_WIDGET (active_view));
-
- /* incremental search is builtin in GeditView, just activate
- * the corresponding binding.
- */
- gtk_bindings_activate (G_OBJECT (active_view),
- GDK_KEY_f,
- GDK_CONTROL_MASK);
+ frame = GEDIT_VIEW_FRAME (_gedit_tab_get_view_frame (active_tab));
+ gedit_view_frame_popup_search (frame);
}
void
@@ -668,38 +661,34 @@ void
_gedit_cmd_search_clear_highlight (GtkAction *action,
GeditWindow *window)
{
- GeditDocument *doc;
+ GeditTab *active_tab;
+ GeditViewFrame *frame;
gedit_debug (DEBUG_COMMANDS);
- doc = gedit_window_get_active_document (window);
- gedit_document_set_search_text (GEDIT_DOCUMENT (doc),
- "",
- GEDIT_SEARCH_DONT_SET_FLAGS);
+ active_tab = gedit_window_get_active_tab (window);
+ if (active_tab == NULL)
+ return;
+
+ frame = GEDIT_VIEW_FRAME (_gedit_tab_get_view_frame (active_tab));
+ gedit_view_frame_clear_text (frame);
}
void
_gedit_cmd_search_goto_line (GtkAction *action,
GeditWindow *window)
{
- GeditView *active_view;
+ GeditTab *active_tab;
+ GeditViewFrame *frame;
gedit_debug (DEBUG_COMMANDS);
- active_view = gedit_window_get_active_view (window);
- if (active_view == NULL)
+ active_tab = gedit_window_get_active_tab (window);
+ if (active_tab == NULL)
return;
- /* Focus the view if needed: we need to focus the view otherwise
- activating the binding for goto line has no effect */
- gtk_widget_grab_focus (GTK_WIDGET (active_view));
-
- /* goto line is builtin in GeditView, just activate
- * the corresponding binding.
- */
- gtk_bindings_activate (G_OBJECT (active_view),
- GDK_KEY_i,
- GDK_CONTROL_MASK);
+ frame = GEDIT_VIEW_FRAME (_gedit_tab_get_view_frame (active_tab));
+ gedit_view_frame_popup_goto_line (frame);
}
/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index d52bd3b..1be2809 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -1261,7 +1261,7 @@ init_search_entry (GeditViewFrame *frame)
}
}
-static gboolean
+static void
start_interactive_search_real (GeditViewFrame *frame)
{
GtkTextBuffer *buffer;
@@ -1278,7 +1278,7 @@ start_interactive_search_real (GeditViewFrame *frame)
}
else
{
- return TRUE;
+ return;
}
}
@@ -1319,8 +1319,6 @@ start_interactive_search_real (GeditViewFrame *frame)
/* We need to grab the focus after the widget has been added */
gtk_widget_grab_focus (frame->priv->search_entry);
-
- return TRUE;
}
static void
@@ -1363,24 +1361,6 @@ view_frame_mount_operation_factory (GeditDocument *doc,
return gtk_mount_operation_new (GTK_WINDOW (window));
}
-static gboolean
-on_start_interactive_search (GeditView *view,
- GeditViewFrame *frame)
-{
- frame->priv->request_search_mode = SEARCH;
-
- return start_interactive_search_real (frame);
-}
-
-static gboolean
-on_start_interactive_goto_line (GeditView *view,
- GeditViewFrame *frame)
-{
- frame->priv->request_search_mode = GOTO_LINE;
-
- return start_interactive_search_real (frame);
-}
-
static void
gedit_view_frame_init (GeditViewFrame *frame)
{
@@ -1404,16 +1384,6 @@ gedit_view_frame_init (GeditViewFrame *frame)
g_object_unref (doc);
- g_signal_connect (frame->priv->view,
- "start-interactive-search",
- G_CALLBACK (on_start_interactive_search),
- frame);
-
- g_signal_connect (frame->priv->view,
- "start-interactive-goto-line",
- G_CALLBACK (on_start_interactive_goto_line),
- frame);
-
/* Create the scrolled window */
sw = gtk_scrolled_window_new (NULL, NULL);
@@ -1477,3 +1447,38 @@ gedit_view_frame_get_view (GeditViewFrame *frame)
return GEDIT_VIEW (frame->priv->view);
}
+
+void
+gedit_view_frame_popup_search (GeditViewFrame *frame)
+{
+ g_return_if_fail (GEDIT_IS_VIEW_FRAME (frame));
+
+ frame->priv->request_search_mode = SEARCH;
+
+ start_interactive_search_real (frame);
+}
+
+void
+gedit_view_frame_popup_goto_line (GeditViewFrame *frame)
+{
+ g_return_if_fail (GEDIT_IS_VIEW_FRAME (frame));
+
+ frame->priv->request_search_mode = GOTO_LINE;
+
+ start_interactive_search_real (frame);
+}
+
+void
+gedit_view_frame_clear_text (GeditViewFrame *frame)
+{
+ GeditDocument *doc;
+
+ g_return_if_fail (GEDIT_IS_VIEW_FRAME (frame));
+
+ doc = gedit_view_frame_get_document (frame);
+
+ gedit_document_set_search_text (doc, "", GEDIT_SEARCH_DONT_SET_FLAGS);
+ gtk_entry_set_text (GTK_ENTRY (frame->priv->search_entry), "");
+
+ gtk_widget_grab_focus (frame->priv->view);
+}
diff --git a/gedit/gedit-view-frame.h b/gedit/gedit-view-frame.h
index 63f033b..93bfc97 100644
--- a/gedit/gedit-view-frame.h
+++ b/gedit/gedit-view-frame.h
@@ -61,6 +61,12 @@ GeditDocument *gedit_view_frame_get_document (GeditViewFrame *frame);
GeditView *gedit_view_frame_get_view (GeditViewFrame *frame);
+void gedit_view_frame_popup_search (GeditViewFrame *frame);
+
+void gedit_view_frame_popup_goto_line (GeditViewFrame *frame);
+
+void gedit_view_frame_clear_text (GeditViewFrame *frame);
+
G_END_DECLS
#endif /* __GEDIT_VIEW_FRAME_H__ */
diff --git a/gedit/gedit-view.c b/gedit/gedit-view.c
index 2514496..24571f7 100644
--- a/gedit/gedit-view.c
+++ b/gedit/gedit-view.c
@@ -80,9 +80,6 @@ G_DEFINE_TYPE(GeditView, gedit_view, GTK_TYPE_SOURCE_VIEW)
/* Signals */
enum
{
- START_INTERACTIVE_SEARCH,
- START_INTERACTIVE_GOTO_LINE,
- RESET_SEARCHED_TEXT,
DROP_URIS,
LAST_SIGNAL
};
@@ -393,18 +390,6 @@ gedit_view_focus_out (GtkWidget *widget, GdkEventFocus *event)
}
static gboolean
-reset_searched_text (GeditView *view)
-{
- GeditDocument *doc;
-
- doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
-
- gedit_document_set_search_text (doc, "", GEDIT_SEARCH_DONT_SET_FLAGS);
-
- return TRUE;
-}
-
-static gboolean
gedit_view_draw (GtkWidget *widget,
cairo_t *cr)
{
@@ -809,37 +794,9 @@ gedit_view_class_init (GeditViewClass *klass)
widget_class->drag_drop = gedit_view_drag_drop;
widget_class->button_press_event = gedit_view_button_press_event;
widget_class->realize = gedit_view_realize;
- klass->reset_searched_text = reset_searched_text;
text_view_class->delete_from_cursor = gedit_view_delete_from_cursor;
- view_signals[START_INTERACTIVE_SEARCH] =
- g_signal_new ("start-interactive-search",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GeditViewClass, start_interactive_search),
- NULL, NULL,
- gedit_marshal_BOOLEAN__NONE,
- G_TYPE_BOOLEAN, 0);
-
- view_signals[START_INTERACTIVE_GOTO_LINE] =
- g_signal_new ("start-interactive-goto-line",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GeditViewClass, start_interactive_goto_line),
- NULL, NULL,
- gedit_marshal_BOOLEAN__NONE,
- G_TYPE_BOOLEAN, 0);
-
- view_signals[RESET_SEARCHED_TEXT] =
- g_signal_new ("reset-searched-text",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GeditViewClass, reset_searched_text),
- NULL, NULL,
- gedit_marshal_BOOLEAN__NONE,
- G_TYPE_BOOLEAN, 0);
-
/* A new signal DROP_URIS has been added to allow plugins to intercept
* the default dnd behaviour of 'text/uri-list'. GeditView now handles
* dnd in the default handlers of drag_drop, drag_motion and
@@ -863,21 +820,6 @@ gedit_view_class_init (GeditViewClass *klass)
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_f,
- GDK_CONTROL_MASK,
- "start-interactive-search", 0);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_i,
- GDK_CONTROL_MASK,
- "start-interactive-goto-line", 0);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_k,
- GDK_CONTROL_MASK | GDK_SHIFT_MASK,
- "reset_searched_text", 0);
-
- gtk_binding_entry_add_signal (binding_set,
GDK_KEY_d,
GDK_CONTROL_MASK,
"delete_from_cursor", 2,
diff --git a/gedit/gedit-view.h b/gedit/gedit-view.h
index 793b5ac..9f9e928 100644
--- a/gedit/gedit-view.h
+++ b/gedit/gedit-view.h
@@ -75,11 +75,6 @@ struct _GeditViewClass
/* FIXME: Do we need placeholders ? */
- /* Key bindings */
- gboolean (* start_interactive_search) (GeditView *view);
- gboolean (* start_interactive_goto_line)(GeditView *view);
- gboolean (* reset_searched_text) (GeditView *view);
-
void (* drop_uris) (GeditView *view,
gchar **uri_list);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]