[anjuta/git-shell: 12/13] git: Add a helper function to remove panes from the dock



commit 63e59bdedea36bc178f80e838bfce3e8684faebd
Author: James Liggett <jrliggett cox net>
Date:   Sat Jul 10 15:54:44 2010 -0700

    git: Add a helper function to remove panes from the dock
    
    Eliminates a lot of repeated code.

 plugins/git/git-add-files-pane.c       |   20 ++++----------------
 plugins/git/git-commit-pane.c          |   20 ++++----------------
 plugins/git/git-create-branch-pane.c   |   20 ++++----------------
 plugins/git/git-delete-branches-pane.c |   18 ++++--------------
 plugins/git/git-merge-pane.c           |   20 ++++----------------
 plugins/git/git-pane.c                 |   11 +++++++++++
 plugins/git/git-pane.h                 |    1 +
 plugins/git/git-pull-pane.c            |   20 ++++----------------
 plugins/git/git-push-pane.c            |   20 ++++----------------
 plugins/git/git-remove-files-pane.c    |   20 ++++----------------
 10 files changed, 44 insertions(+), 126 deletions(-)
---
diff --git a/plugins/git/git-add-files-pane.c b/plugins/git/git-add-files-pane.c
index 132c8cf..35e1469 100644
--- a/plugins/git/git-add-files-pane.c
+++ b/plugins/git/git-add-files-pane.c
@@ -58,19 +58,7 @@ on_ok_button_clicked (GtkButton *button, GitAddFilesPane *self)
 
 	anjuta_command_start (ANJUTA_COMMAND (add_command));
 
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
-}
-
-static void
-on_cancel_button_clicked (GtkButton *button, GitAddFilesPane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 }
 
 static void
@@ -102,9 +90,9 @@ git_add_files_pane_init (GitAddFilesPane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 }
 
 static void
diff --git a/plugins/git/git-commit-pane.c b/plugins/git/git-commit-pane.c
index 88cc2e3..aec8544 100644
--- a/plugins/git/git-commit-pane.c
+++ b/plugins/git/git-commit-pane.c
@@ -187,19 +187,7 @@ on_ok_button_clicked (GtkButton *button, GitCommitPane *self)
 
 	anjuta_command_start (ANJUTA_COMMAND (commit_command));
 
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
-}
-
-static void
-on_cancel_button_clicked (GtkButton *button, GitCommitPane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE(self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 }
 
 static void
@@ -257,9 +245,9 @@ git_commit_pane_init (GitCommitPane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 	
 }
 
diff --git a/plugins/git/git-create-branch-pane.c b/plugins/git/git-create-branch-pane.c
index 18fba20..959587b 100644
--- a/plugins/git/git-create-branch-pane.c
+++ b/plugins/git/git-create-branch-pane.c
@@ -95,19 +95,7 @@ on_ok_button_clicked (GtkButton *button, GitCreateBranchPane *self)
 	g_free (name);
 	g_free (revision);
 
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
-}
-
-static void
-on_cancel_button_clicked (GtkButton *button, GitCreateBranchPane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock),
-	                         ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 }
 
 static void
@@ -154,9 +142,9 @@ git_create_branch_pane_init (GitCreateBranchPane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 
 	g_signal_connect (G_OBJECT (revision_radio), "toggled",
 	                  G_CALLBACK (on_revision_radio_toggled),
diff --git a/plugins/git/git-delete-branches-pane.c b/plugins/git/git-delete-branches-pane.c
index 58f7197..1d92e34 100644
--- a/plugins/git/git-delete-branches-pane.c
+++ b/plugins/git/git-delete-branches-pane.c
@@ -104,21 +104,11 @@ on_ok_button_clicked (GtkButton *button, GitDeleteBranchesPane *self)
 	}
 
 
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 	                            
 }
 
 static void
-on_cancel_button_clicked (GtkButton *button, GitDeleteBranchesPane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), ANJUTA_DOCK_PANE (self));
-}
-
-static void
 git_delete_branches_pane_init (GitDeleteBranchesPane *self)
 {
 	gchar *objects[] = {"delete_branches_pane",
@@ -147,9 +137,9 @@ git_delete_branches_pane_init (GitDeleteBranchesPane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 }
 
 static void
diff --git a/plugins/git/git-merge-pane.c b/plugins/git/git-merge-pane.c
index e3b59c9..758b0c2 100644
--- a/plugins/git/git-merge-pane.c
+++ b/plugins/git/git-merge-pane.c
@@ -100,19 +100,7 @@ on_ok_button_clicked (GtkButton *button, GitMergePane *self)
 	anjuta_command_start (ANJUTA_COMMAND (merge_command));
 	                                       
 
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
-}
-
-static void
-on_cancel_button_clicked (GtkButton *button, GitMergePane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock),
-	                         ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 }
 
 static void
@@ -168,9 +156,9 @@ git_merge_pane_init (GitMergePane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 
 	g_signal_connect (G_OBJECT (use_custom_log_check), "toggled",
 	                  G_CALLBACK (on_use_custom_log_check_toggled),
diff --git a/plugins/git/git-pane.c b/plugins/git/git-pane.c
index 264cd9d..4c195a4 100644
--- a/plugins/git/git-pane.c
+++ b/plugins/git/git-pane.c
@@ -48,6 +48,17 @@ git_pane_class_init (GitPaneClass *klass)
 	object_class->finalize = git_pane_finalize;
 }
 
+void
+git_pane_remove_from_dock (GitPane *self)
+{
+	Git *plugin;
+
+	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
+
+	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
+	                         ANJUTA_DOCK_PANE (self));
+}
+
 static void
 on_message_view_destroyed (Git* plugin, gpointer destroyed_view)
 {
diff --git a/plugins/git/git-pane.h b/plugins/git/git-pane.h
index cdfd8b0..3436cb2 100644
--- a/plugins/git/git-pane.h
+++ b/plugins/git/git-pane.h
@@ -48,6 +48,7 @@ struct _GitPane
 };
 
 GType git_pane_get_type (void) G_GNUC_CONST;
+void git_pane_remove_from_dock (GitPane *self);
 
 /* Static helper methods */
 void git_pane_create_message_view (Git *plugin);
diff --git a/plugins/git/git-pull-pane.c b/plugins/git/git-pull-pane.c
index 9dfd8cc..9886624 100644
--- a/plugins/git/git-pull-pane.c
+++ b/plugins/git/git-pull-pane.c
@@ -98,19 +98,7 @@ on_ok_button_clicked (GtkButton *button, GitPullPane *self)
 
 	anjuta_command_start (ANJUTA_COMMAND (pull_command));
 	
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
-}
-
-static void
-on_cancel_button_clicked (GtkButton *button, GitPullPane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 }
 
 static void
@@ -160,9 +148,9 @@ git_pull_pane_init (GitPullPane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 }
 
 static void
diff --git a/plugins/git/git-push-pane.c b/plugins/git/git-push-pane.c
index 8fa924f..ec5318c 100644
--- a/plugins/git/git-push-pane.c
+++ b/plugins/git/git-push-pane.c
@@ -139,19 +139,7 @@ on_ok_button_clicked (GtkButton *button, GitPushPane *self)
 
 	anjuta_command_start (ANJUTA_COMMAND (push_command));
 
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
-}
-
-static void
-on_cancel_button_clicked (GtkButton *button, GitPushPane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 }
 
 static void
@@ -303,9 +291,9 @@ git_push_pane_init (GitPushPane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 
 	g_signal_connect (G_OBJECT (branches_selected_renderer), "toggled",
 	                  G_CALLBACK (on_selected_renderer_toggled),
diff --git a/plugins/git/git-remove-files-pane.c b/plugins/git/git-remove-files-pane.c
index 63b11dc..96324ec 100644
--- a/plugins/git/git-remove-files-pane.c
+++ b/plugins/git/git-remove-files-pane.c
@@ -58,19 +58,7 @@ on_ok_button_clicked (GtkButton *button, GitRemoveFilesPane *self)
 
 	anjuta_command_start (ANJUTA_COMMAND (remove_command));
 
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
-}
-
-static void
-on_cancel_button_clicked (GtkButton *button, GitRemoveFilesPane *self)
-{
-	Git *plugin;
-
-	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));
-
-	anjuta_dock_remove_pane (ANJUTA_DOCK (plugin->dock), 
-	                         ANJUTA_DOCK_PANE (self));
+	git_pane_remove_from_dock (GIT_PANE (self));
 }
 
 static void
@@ -102,9 +90,9 @@ git_remove_files_pane_init (GitRemoveFilesPane *self)
 	                  G_CALLBACK (on_ok_button_clicked),
 	                  self);
 
-	g_signal_connect (G_OBJECT (cancel_button), "clicked",
-	                  G_CALLBACK (on_cancel_button_clicked),
-	                  self);
+	g_signal_connect_swapped (G_OBJECT (cancel_button), "clicked",
+	                          G_CALLBACK (git_pane_remove_from_dock),
+	                          self);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]