[gthumb/ext: 4/15] removed unused commands from the UI



commit 1470aa37100cd6001f113536ace50705ed82b6b6
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Dec 8 00:18:52 2009 +0100

    removed unused commands from the UI

 extensions/search/actions.c   |   96 ----------------------------------------
 extensions/search/actions.h   |    1 -
 extensions/search/callbacks.c |   97 +++--------------------------------------
 extensions/search/callbacks.h |    3 -
 extensions/search/main.c      |    1 -
 5 files changed, 7 insertions(+), 191 deletions(-)
---
diff --git a/extensions/search/actions.c b/extensions/search/actions.c
index fb84241..95decc9 100644
--- a/extensions/search/actions.c
+++ b/extensions/search/actions.c
@@ -112,102 +112,6 @@ search_data_free (SearchData *search_data)
 
 
 static void
-search_edit_response_cb (GtkDialog *dialog,
-			 int        response,
-			 gpointer   user_data)
-{
-	SearchData *search_data = user_data;
-	GthSearch  *search;
-	GError     *error = NULL;
-	GthTask    *task;
-
-	if (response != GTK_RESPONSE_OK) {
-		gtk_widget_destroy (GTK_WIDGET (dialog));
-		search_data_free (search_data);
-		return;
-	}
-
-	search = gth_search_editor_dialog_get_search (GTH_SEARCH_EDITOR_DIALOG (dialog), &error);
-	if (search == NULL) {
-		_gtk_error_dialog_from_gerror_show (GTK_WINDOW (dialog), _("Could not perform the search"), &error);
-		search_data_free (search_data);
-		return;
-	}
-
-        task = gth_search_task_new (search_data->browser, search, search_data->file);
-	gth_browser_exec_task (search_data->browser, task, TRUE);
-
-	gtk_widget_destroy (GTK_WIDGET (dialog));
-
-	g_object_unref (task);
-	g_object_unref (search);
-	search_data_free (search_data);
-}
-
-
-static void
-search_edit_buffer_ready_cb (void     *buffer,
-			     gsize     count,
-			     GError   *error,
-			     gpointer  user_data)
-{
-	SearchData *search_data = user_data;
-	GError     *local_error = NULL;
-	GthSearch  *search;
-	GtkWidget  *dialog;
-
-	if (error != NULL) {
-		_gtk_error_dialog_from_gerror_show (GTK_WINDOW (search_data->browser), _("Could not perform the search"), &error);
-		return;
-	}
-
-	search = gth_search_new_from_data (buffer, count, &local_error);
-	if (search == NULL) {
-		_gtk_error_dialog_from_gerror_show (GTK_WINDOW (search_data->browser), _("Could not perform the search"), &local_error);
-		return;
-	}
-
-	dialog = gth_search_editor_dialog_new (_("Find"), search, GTK_WINDOW (search_data->browser));
-	gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-	gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_FIND, GTK_RESPONSE_OK);
-
-	g_signal_connect (dialog, "response",
-			  G_CALLBACK (search_edit_response_cb),
-			  search_data);
-
-	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-	gtk_window_present (GTK_WINDOW (dialog));
-
-	g_object_unref (search);
-}
-
-
-void
-gth_browser_activate_action_edit_search_edit (GtkAction  *action,
-					      GthBrowser *browser)
-{
-	GFile      *location;
-	SearchData *search_data;
-	GFile      *file;
-
-	location = gth_browser_get_location (browser);
-
-	search_data = g_new0 (SearchData, 1);
-	search_data->browser = browser;
-	search_data->file = g_file_dup (location);
-
-	file = gth_main_get_gio_file (location);
-	g_load_file_async (file,
-			   G_PRIORITY_DEFAULT,
-			   NULL,
-			   search_edit_buffer_ready_cb,
-			   search_data);
-
-	g_object_unref (file);
-}
-
-
-static void
 search_update_buffer_ready_cb (void     *buffer,
 			       gsize     count,
 			       GError   *error,
diff --git a/extensions/search/actions.h b/extensions/search/actions.h
index 0d996dc..bbb9b2e 100644
--- a/extensions/search/actions.h
+++ b/extensions/search/actions.h
@@ -28,7 +28,6 @@
 #define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
 
 DEFINE_ACTION(gth_browser_activate_action_edit_find)
-DEFINE_ACTION(gth_browser_activate_action_edit_search_edit)
 DEFINE_ACTION(gth_browser_activate_action_edit_search_update)
 
 #endif /* ACTIONS_H */
diff --git a/extensions/search/callbacks.c b/extensions/search/callbacks.c
index 9b0f7c4..b0e064e 100644
--- a/extensions/search/callbacks.c
+++ b/extensions/search/callbacks.c
@@ -61,43 +61,9 @@ static GtkActionEntry find_action_entries[] = {
 static guint find_action_entries_size = G_N_ELEMENTS (find_action_entries);
 
 
-static const char *search_ui_info =
-"<ui>"
-"  <menubar name='MenuBar'>"
-"    <menu name='Edit' action='EditMenu'>"
-"      <placeholder name='Edit_Actions'>"
-"        <menuitem action='Edit_Search_Edit'/>"
-"        <menuitem action='Edit_Search_Update'/>"
-"      </placeholder>"
-"    </menu>"
-"  </menubar>"
-"  <toolbar name='ToolBar'>"
-"    <placeholder name='SourceCommands'>"
-"      <toolitem action='Edit_Search_Edit'/>"
-"      <toolitem action='Edit_Search_Update'/>"
-"    </placeholder>"
-"  </toolbar>"
-"</ui>";
-
-
-static GtkActionEntry search_actions_entries[] = {
-	{ "Edit_Search_Edit", GTK_STOCK_FIND_AND_REPLACE,
-	  N_("Edit Search"), "<ctrl>F",
-	  N_("Edit search criteria"),
-	  G_CALLBACK (gth_browser_activate_action_edit_search_edit) },
-	{ "Edit_Search_Update", GTK_STOCK_REFRESH,
-	  N_("Redo Search"), "<shift><ctrl>R",
-	  N_("Update search results"),
-	  G_CALLBACK (gth_browser_activate_action_edit_search_update) }
-};
-static guint search_actions_entries_size = G_N_ELEMENTS (search_actions_entries);
-
-
 typedef struct {
 	GtkActionGroup *find_action;
 	guint           find_merge_id;
-	GtkActionGroup *search_actions;
-	guint           search_merge_id;
 	GtkWidget      *refresh_button;
 } BrowserData;
 
@@ -113,6 +79,7 @@ void
 search__gth_browser_construct_cb (GthBrowser *browser)
 {
 	BrowserData *data;
+	GError      *error = NULL;
 
 	g_return_if_fail (GTH_IS_BROWSER (browser));
 
@@ -126,13 +93,12 @@ search__gth_browser_construct_cb (GthBrowser *browser)
 				      browser);
 	gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->find_action, 0);
 
-	data->search_actions = gtk_action_group_new ("Search Actions");
-	gtk_action_group_set_translation_domain (data->search_actions, NULL);
-	gtk_action_group_add_actions (data->search_actions,
-				      search_actions_entries,
-				      search_actions_entries_size,
-				      browser);
-	gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->search_actions, 0);
+	data->find_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), find_ui_info, -1, &error);
+	if (data->find_merge_id == 0) {
+		g_warning ("building menus failed: %s", error->message);
+		g_error_free (error);
+	}
+	gtk_tool_item_set_is_important (GTK_TOOL_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/ToolBar/SourceCommands/Edit_Find")), TRUE);
 
 	g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
 }
@@ -147,43 +113,6 @@ refresh_button_clicked_cb (GtkButton  *button,
 
 
 void
-search__gth_browser_load_location_after_cb (GthBrowser   *browser,
-					    GthFileData  *location_data,
-					    const GError *error)
-{
-	BrowserData *data;
-
-	if ((location_data == NULL) || (error != NULL))
-		return;
-
-	data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
-
-	if (_g_content_type_is_a (g_file_info_get_content_type (location_data->info), "gthumb/search")) {
-		if (data->find_merge_id != 0) {
-			gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->find_merge_id);
-			data->find_merge_id = 0;
-		}
-	}
-	else {
-		if (data->search_merge_id != 0) {
-			gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (browser), data->search_merge_id);
-			data->search_merge_id = 0;
-		}
-		if (data->find_merge_id == 0) {
-			GError *local_error = NULL;
-
-			data->find_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), find_ui_info, -1, &local_error);
-			if (data->find_merge_id == 0) {
-				g_warning ("building menus failed: %s", local_error->message);
-				g_error_free (local_error);
-			}
-			gtk_tool_item_set_is_important (GTK_TOOL_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/ToolBar/SourceCommands/Edit_Find")), TRUE);
-		}
-	}
-}
-
-
-void
 search__gth_browser_update_extra_widget_cb (GthBrowser *browser)
 {
 	GthFileData *location_data;
@@ -195,18 +124,6 @@ search__gth_browser_update_extra_widget_cb (GthBrowser *browser)
 
 	data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
 
-	if (data->search_merge_id == 0) {
-		GError *local_error = NULL;
-
-		data->search_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), search_ui_info, -1, &local_error);
-		if (data->search_merge_id == 0) {
-			g_warning ("building menus failed: %s", local_error->message);
-			g_error_free (local_error);
-		}
-		/*gtk_tool_item_set_is_important (GTK_TOOL_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/ToolBar/SourceCommands/Edit_Search_Update")), TRUE);*/
-		gtk_tool_item_set_is_important (GTK_TOOL_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/ToolBar/SourceCommands/Edit_Search_Edit")), TRUE);
-	}
-
 	if (data->refresh_button == NULL) {
 		data->refresh_button = gtk_button_new ();
 		gtk_container_add (GTK_CONTAINER (data->refresh_button), gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON));
diff --git a/extensions/search/callbacks.h b/extensions/search/callbacks.h
index cda1eb7..7c5d25d 100644
--- a/extensions/search/callbacks.h
+++ b/extensions/search/callbacks.h
@@ -28,9 +28,6 @@
 
 void         search__gth_browser_construct_cb            (GthBrowser  *browser);
 void         search__gth_browser_update_sensitivity_cb   (GthBrowser  *browser);
-void         search__gth_browser_load_location_after_cb  (GthBrowser  *browser,
-						          GFile       *location,
-						          GError      *error);
 void         search__gth_browser_update_extra_widget_cb  (GthBrowser  *browser);
 GthCatalog * search__gth_catalog_load_from_data_cb       (const void  *buffer);
 void         search__dlg_catalog_properties              (GthBrowser  *browser,
diff --git a/extensions/search/main.c b/extensions/search/main.c
index 22f9a15..2bf20de 100644
--- a/extensions/search/main.c
+++ b/extensions/search/main.c
@@ -32,7 +32,6 @@ gthumb_extension_activate (void)
 {
 	gth_hook_add_callback ("gth-catalog-load-from-data", 10, G_CALLBACK (search__gth_catalog_load_from_data_cb), NULL);
 	gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (search__gth_browser_construct_cb), NULL);
-	gth_hook_add_callback ("gth-browser-load-location-after", 20, G_CALLBACK (search__gth_browser_load_location_after_cb), NULL);
 	gth_hook_add_callback ("gth-browser-update-extra-widget", 20, G_CALLBACK (search__gth_browser_update_extra_widget_cb), NULL);
 	gth_hook_add_callback ("dlg-catalog-properties", 10, G_CALLBACK (search__dlg_catalog_properties), NULL);
 }



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