[nautilus] slot: refactor some code
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] slot: refactor some code
- Date: Tue, 2 Oct 2012 19:53:14 +0000 (UTC)
commit 86fde912f3850a984a38e7e41d8290eb0d996562
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Oct 2 15:50:23 2012 -0400
slot: refactor some code
Factor out two functions, to show and hide the query editor, and use
them from nautilus_window_slot_set_query_editor_visible()
src/nautilus-window-slot.c | 74 ++++++++++++++++++++++----------------------
1 files changed, 37 insertions(+), 37 deletions(-)
---
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 87bc777..43f3405 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -186,7 +186,28 @@ query_editor_changed_callback (NautilusQueryEditor *editor,
}
static void
-update_query_editor (NautilusWindowSlot *slot)
+hide_query_editor (NautilusWindowSlot *slot)
+{
+ gtk_widget_hide (GTK_WIDGET (slot->query_editor));
+
+ if (slot->qe_changed_id > 0) {
+ g_signal_handler_disconnect (slot->query_editor, slot->qe_changed_id);
+ slot->qe_changed_id = 0;
+ }
+ if (slot->qe_cancel_id > 0) {
+ g_signal_handler_disconnect (slot->query_editor, slot->qe_cancel_id);
+ slot->qe_cancel_id = 0;
+ }
+ if (slot->qe_activated_id > 0) {
+ g_signal_handler_disconnect (slot->query_editor, slot->qe_activated_id);
+ slot->qe_activated_id = 0;
+ }
+
+ nautilus_query_editor_set_query (slot->query_editor, NULL);
+}
+
+static void
+show_query_editor (NautilusWindowSlot *slot)
{
NautilusDirectory *directory;
NautilusSearchDirectory *search_directory;
@@ -220,17 +241,22 @@ update_query_editor (NautilusWindowSlot *slot)
}
nautilus_directory_unref (directory);
-}
-
-static void
-ensure_query_editor (NautilusWindowSlot *slot)
-{
- g_assert (slot->query_editor != NULL);
-
- update_query_editor (slot);
gtk_widget_show (GTK_WIDGET (slot->query_editor));
gtk_widget_grab_focus (GTK_WIDGET (slot->query_editor));
+
+ if (slot->qe_changed_id == 0) {
+ slot->qe_changed_id = g_signal_connect (slot->query_editor, "changed",
+ G_CALLBACK (query_editor_changed_callback), slot);
+ }
+ if (slot->qe_cancel_id == 0) {
+ slot->qe_cancel_id = g_signal_connect (slot->query_editor, "cancel",
+ G_CALLBACK (query_editor_cancel_callback), slot);
+ }
+ if (slot->qe_activated_id == 0) {
+ slot->qe_activated_id = g_signal_connect (slot->query_editor, "activated",
+ G_CALLBACK (query_editor_activated_callback), slot);
+ }
}
void
@@ -238,35 +264,9 @@ nautilus_window_slot_set_query_editor_visible (NautilusWindowSlot *slot,
gboolean visible)
{
if (visible) {
- ensure_query_editor (slot);
-
- if (slot->qe_changed_id == 0)
- slot->qe_changed_id = g_signal_connect (slot->query_editor, "changed",
- G_CALLBACK (query_editor_changed_callback), slot);
- if (slot->qe_cancel_id == 0)
- slot->qe_cancel_id = g_signal_connect (slot->query_editor, "cancel",
- G_CALLBACK (query_editor_cancel_callback), slot);
- if (slot->qe_activated_id == 0)
- slot->qe_activated_id = g_signal_connect (slot->query_editor, "activated",
- G_CALLBACK (query_editor_activated_callback), slot);
-
+ show_query_editor (slot);
} else {
- gtk_widget_hide (GTK_WIDGET (slot->query_editor));
-
- if (slot->qe_changed_id > 0) {
- g_signal_handler_disconnect (slot->query_editor, slot->qe_changed_id);
- slot->qe_changed_id = 0;
- }
- if (slot->qe_cancel_id > 0) {
- g_signal_handler_disconnect (slot->query_editor, slot->qe_cancel_id);
- slot->qe_cancel_id = 0;
- }
- if (slot->qe_activated_id > 0) {
- g_signal_handler_disconnect (slot->query_editor, slot->qe_activated_id);
- slot->qe_activated_id = 0;
- }
-
- nautilus_query_editor_set_query (slot->query_editor, NULL);
+ hide_query_editor (slot);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]