Commit 6056b620 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

started porting of the context menus to GMenu

parent 82c90a9f
......@@ -699,9 +699,9 @@ catalogs__gth_browser_update_extra_widget_cb (GthBrowser *browser)
gtk_button_set_relief (GTK_BUTTON (data->properties_button), GTK_RELIEF_NONE);
gtk_widget_set_tooltip_text (data->properties_button, _("Catalog Properties"));
gtk_widget_show_all (data->properties_button);
gedit_message_area_add_action_widget (GEDIT_MESSAGE_AREA (gth_browser_get_list_extra_widget (browser)),
data->properties_button,
_RESPONSE_PROPERTIES);
gtk_info_bar_add_action_widget (GTK_INFO_BAR (gth_browser_get_list_extra_widget (browser)),
data->properties_button,
_RESPONSE_PROPERTIES);
g_signal_connect (data->properties_button,
"clicked",
G_CALLBACK (properties_button_clicked_cb),
......@@ -716,9 +716,9 @@ catalogs__gth_browser_update_extra_widget_cb (GthBrowser *browser)
g_object_add_weak_pointer (G_OBJECT (data->organize_button), (gpointer *)&data->organize_button);
gtk_button_set_relief (GTK_BUTTON (data->organize_button), GTK_RELIEF_NONE);
gtk_widget_show_all (data->organize_button);
gedit_message_area_add_action_widget (GEDIT_MESSAGE_AREA (gth_browser_get_list_extra_widget (browser)),
data->organize_button,
_RESPONSE_ORGANIZE);
gtk_info_bar_add_action_widget (GTK_INFO_BAR (gth_browser_get_list_extra_widget (browser)),
data->organize_button,
_RESPONSE_ORGANIZE);
g_signal_connect (data->organize_button,
"clicked",
G_CALLBACK (organize_button_clicked_cb),
......
......@@ -289,9 +289,11 @@ copy_wallpaper_ready_cb (GObject *source_object,
void
gth_browser_activate_action_tool_desktop_background (GtkAction *action,
GthBrowser *browser)
gth_browser_activate_set_desktop_background (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GthBrowser *browser = GTH_BROWSER (user_data);
WallpaperData *wdata;
gboolean saving_wallpaper = FALSE;
GList *items;
......@@ -359,3 +361,11 @@ gth_browser_activate_action_tool_desktop_background (GtkAction *action,
_g_object_list_unref (file_list);
_gtk_tree_path_list_free (items);
}
void
gth_browser_activate_action_tool_desktop_background (GtkAction *action,
GthBrowser *browser)
{
gth_browser_activate_set_desktop_background (NULL, NULL, browser);
}
......@@ -22,10 +22,11 @@
#ifndef ACTIONS_H
#define ACTIONS_H
#include <gtk/gtk.h>
#include <gthumb.h>
#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
DEFINE_ACTION(gth_browser_activate_action_tool_desktop_background)
DEFINE_ACTION (gth_browser_activate_action_tool_desktop_background)
DEF_ACTION_CALLBACK (gth_browser_activate_set_desktop_background)
#endif /* ACTIONS_H */
......@@ -26,84 +26,41 @@
#include <gthumb.h>
#include "actions.h"
#define BROWSER_DATA_KEY "desktop-background-browser-data"
static const char *fixed_ui_info =
"<ui>"
" <popup name='FileListPopup'>"
" <placeholder name='Screen_Actions'>"
" <menuitem name='DesktopBackground' action='Tool_DesktopBackground'/>"
" </placeholder>"
" </popup>"
" <popup name='FilePopup'>"
" <placeholder name='Screen_Actions'>"
" <menuitem name='DesktopBackground' action='Tool_DesktopBackground'/>"
" </placeholder>"
" </popup>"
"</ui>";
static GtkActionEntry action_entries[] = {
{ "Tool_DesktopBackground", "desktop",
N_("Set as Desktop Background"), NULL,
N_("Set the image as desktop background"),
G_CALLBACK (gth_browser_activate_action_tool_desktop_background) },
static const GActionEntry actions[] = {
{ "set-desktop-background", gth_browser_activate_set_desktop_background }
};
typedef struct {
GtkActionGroup *action_group;
} BrowserData;
static void
browser_data_free (BrowserData *data)
{
g_free (data);
}
void
db__gth_browser_construct_cb (GthBrowser *browser)
{
BrowserData *data;
GError *error = NULL;
g_return_if_fail (GTH_IS_BROWSER (browser));
data = g_new0 (BrowserData, 1);
data->action_group = gtk_action_group_new ("Desktop Background Actions");
gtk_action_group_set_translation_domain (data->action_group, NULL);
gtk_action_group_add_actions (data->action_group,
action_entries,
G_N_ELEMENTS (action_entries),
browser);
gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0);
if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) {
g_message ("building menus failed: %s", error->message);
g_clear_error (&error);
}
g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
g_action_map_add_action_entries (G_ACTION_MAP (browser),
actions,
G_N_ELEMENTS (actions),
browser);
gth_menu_manager_append_entry (gth_browser_get_menu_manager (browser, GTH_BROWSER_MENU_MANAGER_FILE_SCREEN_ACTIONS),
GTH_MENU_MANAGER_NEW_MERGE_ID,
_("Set as Desktop Background"),
"win.set-desktop-background",
NULL,
NULL);
gth_menu_manager_append_entry (gth_browser_get_menu_manager (browser, GTH_BROWSER_MENU_MANAGER_FILE_LIST_SCREEN_ACTIONS),
GTH_MENU_MANAGER_NEW_MERGE_ID,
_("Set as Desktop Background"),
"win.set-desktop-background",
NULL,
NULL);
}
void
db__gth_browser_update_sensitivity_cb (GthBrowser *browser)
{
BrowserData *data;
GtkAction *action;
int n_selected;
gboolean sensitive;
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
g_return_if_fail (data != NULL);
int n_selected;
n_selected = gth_file_selection_get_n_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
sensitive = n_selected == 1;
action = gtk_action_group_get_action (data->action_group, "Tool_DesktopBackground");
g_object_set (action, "sensitive", sensitive, NULL);
g_object_set (g_action_map_lookup_action (G_ACTION_MAP (browser), "set-desktop-background"), "enabled", n_selected == 1, NULL);
}
......@@ -45,107 +45,21 @@ static const GthMenuEntry action_entries[] = {
};
static const char *fixed_ui_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='Edit' action='EditMenu'>"
" <placeholder name='Edit_Actions'>"
" <menuitem action='Edit_Metadata'/>"
" </placeholder>"
" </menu>"
" </menubar>"
" <toolbar name='Fullscreen_ToolBar'>"
" <placeholder name='Edit_Actions'>"
" <toolitem action='Edit_Metadata'/>"
" </placeholder>"
" </toolbar>"
" <popup name='FileListPopup'>"
" <placeholder name='File_LastActions'>"
" <menuitem action='Edit_Tags'/>"
" <menuitem action='Edit_Metadata'/>"
" </placeholder>"
" </popup>"
" <popup name='FilePopup'>"
" <placeholder name='File_LastActions'>"
" <menuitem action='Edit_Tags'/>"
" <menuitem action='Edit_Metadata'/>"
" </placeholder>"
" </popup>"
"</ui>";
static GthActionEntryExt edit_metadata_action_entries[] = {
{ "Edit_QuickTag", "tag", N_("T_ags") },
{ "Edit_Metadata", GTK_STOCK_EDIT,
N_("Comment"), "<control>M",
N_("Edit the comment and other information of the selected files"),
GTH_ACTION_FLAG_IS_IMPORTANT,
G_CALLBACK (gth_browser_activate_action_edit_comment) },
{ "Edit_Tags", "tag",
N_("Tags"), NULL,
N_("Set the tags of the selected files"),
GTH_ACTION_FLAG_NONE,
G_CALLBACK (gth_browser_activate_action_edit_tags) }
};
typedef struct {
GthBrowser *browser;
GtkActionGroup *actions;
guint viewer_ui_merge_id;
} BrowserData;
static void
browser_data_free (BrowserData *data)
{
g_free (data);
}
void
edit_metadata__gth_browser_construct_cb (GthBrowser *browser)
{
BrowserData *data;
GError *error = NULL;
g_return_if_fail (GTH_IS_BROWSER (browser));
if (gth_main_extension_is_active ("list_tools")) {
g_action_map_add_action_entries (G_ACTION_MAP (browser),
actions,
G_N_ELEMENTS (actions),
browser);
gth_menu_manager_append_entries (gth_browser_get_menu_manager (browser, GTH_BROWSER_MENU_MANAGER_TOOLS2),
action_entries,
G_N_ELEMENTS (action_entries));
}
data = g_new0 (BrowserData, 1);
data->browser = browser;
data->actions = gtk_action_group_new ("Edit Metadata Actions");
gtk_action_group_set_translation_domain (data->actions, NULL);
_gtk_action_group_add_actions_with_flags (data->actions,
edit_metadata_action_entries,
G_N_ELEMENTS (edit_metadata_action_entries),
browser);
gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->actions, 0);
if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) {
g_message ("building menus failed: %s", error->message);
g_error_free (error);
}
g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
g_action_map_add_action_entries (G_ACTION_MAP (browser),
actions,
G_N_ELEMENTS (actions),
browser);
if (gth_main_extension_is_active ("list_tools"))
gth_menu_manager_append_entries (gth_browser_get_menu_manager (browser, GTH_BROWSER_MENU_MANAGER_TOOLS2),
action_entries,
G_N_ELEMENTS (action_entries));
gth_browser_add_header_bar_button (browser,
GTH_BROWSER_HEADER_SECTION_BROWSER_EDIT,
"comment-symbolic",
......@@ -176,21 +90,15 @@ edit_metadata__gth_browser_construct_cb (GthBrowser *browser)
void
edit_metadata__gth_browser_update_sensitivity_cb (GthBrowser *browser)
{
BrowserData *data;
int n_selected;
gboolean sensitive;
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
g_return_if_fail (data != NULL);
int n_selected;
gboolean sensitive;
n_selected = gth_file_selection_get_n_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
sensitive = (n_selected > 0);
g_object_set (gtk_action_group_get_action (data->actions, "Edit_Metadata"), "sensitive", sensitive, NULL);
g_object_set (g_action_map_lookup_action (G_ACTION_MAP (data->browser), "edit-metadata"), "enabled", sensitive, NULL);
g_object_set (g_action_map_lookup_action (G_ACTION_MAP (data->browser), "edit-tags"), "enabled", sensitive, NULL);
g_object_set (g_action_map_lookup_action (G_ACTION_MAP (data->browser), "delete-metadata"), "enabled", sensitive, NULL);
g_object_set (g_action_map_lookup_action (G_ACTION_MAP (browser), "edit-metadata"), "enabled", sensitive, NULL);
g_object_set (g_action_map_lookup_action (G_ACTION_MAP (browser), "edit-tags"), "enabled", sensitive, NULL);
g_object_set (g_action_map_lookup_action (G_ACTION_MAP (browser), "delete-metadata"), "enabled", sensitive, NULL);
}
......
This diff is collapsed.
......@@ -22,30 +22,30 @@
#ifndef ACTIONS_H
#define ACTIONS_H
#include <gtk/gtk.h>
#include <gthumb.h>
#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
DEF_ACTION_CALLBACK (gth_browser_activate_create_folder)
DEF_ACTION_CALLBACK (gth_browser_activate_edit_cut)
DEF_ACTION_CALLBACK (gth_browser_activate_edit_copy)
DEF_ACTION_CALLBACK (gth_browser_activate_edit_paste)
DEF_ACTION_CALLBACK (gth_browser_activate_duplicate)
DEF_ACTION_CALLBACK (gth_browser_activate_trash)
DEF_ACTION_CALLBACK (gth_browser_activate_delete)
DEF_ACTION_CALLBACK (gth_browser_activate_rename)
DEF_ACTION_CALLBACK (gth_browser_activate_copy_to_folder)
DEF_ACTION_CALLBACK (gth_browser_activate_move_to_folder)
DEFINE_ACTION(gth_browser_action_new_folder)
DEFINE_ACTION(gth_browser_action_rename_folder)
DEFINE_ACTION(gth_browser_activate_action_edit_cut_files)
DEFINE_ACTION(gth_browser_activate_action_edit_copy_files)
DEFINE_ACTION(gth_browser_activate_action_edit_paste)
DEFINE_ACTION(gth_browser_activate_action_edit_duplicate)
DEFINE_ACTION(gth_browser_activate_action_edit_trash)
DEFINE_ACTION(gth_browser_activate_action_edit_delete)
DEFINE_ACTION(gth_browser_activate_action_edit_rename)
DEFINE_ACTION(gth_browser_activate_action_folder_open_in_file_manager)
DEFINE_ACTION(gth_browser_activate_action_folder_create)
DEFINE_ACTION(gth_browser_activate_action_folder_rename)
DEFINE_ACTION(gth_browser_activate_action_folder_cut)
DEFINE_ACTION(gth_browser_activate_action_folder_copy)
DEFINE_ACTION(gth_browser_activate_action_folder_paste)
DEFINE_ACTION(gth_browser_activate_action_folder_trash)
DEFINE_ACTION(gth_browser_activate_action_folder_delete)
DEFINE_ACTION(gth_browser_activate_action_folder_copy_to_folder)
DEFINE_ACTION(gth_browser_activate_action_folder_move_to_folder)
DEFINE_ACTION(gth_browser_activate_action_tool_copy_to_folder)
DEFINE_ACTION(gth_browser_activate_action_tool_move_to_folder)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_open_in_file_manager)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_create)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_rename)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_cut)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_copy)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_paste_into_folder)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_trash)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_delete)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_copy_to)
DEF_ACTION_CALLBACK (gth_browser_activate_folder_context_move_to)
DEF_ACTION_CALLBACK (gth_browser_activate_open_with_application)
#endif /* ACTIONS_H */
This diff is collapsed.
......@@ -27,8 +27,9 @@
void
gth_browser_activate_action_edit_find_duplicates (GtkAction *action,
GthBrowser *browser)
gth_browser_activate_find_duplicates (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
dlg_find_duplicates (browser);
dlg_find_duplicates (GTH_BROWSER (user_data));
}
......@@ -22,10 +22,8 @@
#ifndef ACTIONS_H
#define ACTIONS_H
#include <gtk/gtk.h>
#include <gthumb.h>
#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
DEFINE_ACTION(gth_browser_activate_action_edit_find_duplicates)
DEF_ACTION_CALLBACK (gth_browser_activate_find_duplicates)
#endif /* ACTIONS_H */
......@@ -28,67 +28,26 @@
#include "callbacks.h"
#define BROWSER_DATA_KEY "find-duplicates-browser-data"
static const char *find_ui_info =
"<ui>"
" <menubar name='MenuBar'>"
" <menu name='Edit' action='EditMenu'>"
" <placeholder name='Edit_Actions'>"
" <menuitem action='Edit_Find_Duplicates'/>"
" </placeholder>"
" </menu>"
" </menubar>"
"</ui>";
static GtkActionEntry find_action_entries[] = {
{ "Edit_Find_Duplicates", NULL,
N_("Find _Duplicates..."), NULL,
N_("Find duplicated files in the current location"),
G_CALLBACK (gth_browser_activate_action_edit_find_duplicates) }
static const GActionEntry actions[] = {
{ "find-duplicates", gth_browser_activate_find_duplicates }
};
static guint find_action_entries_size = G_N_ELEMENTS (find_action_entries);
typedef struct {
GtkActionGroup *find_action;
guint find_merge_id;
GtkWidget *refresh_button;
} BrowserData;
static void
browser_data_free (BrowserData *data)
{
g_free (data);
}
static const GthMenuEntry action_entries[] = {
{ N_("Find _Duplicates..."), "win.find-duplicates" }
};
void
find_dup__gth_browser_construct_cb (GthBrowser *browser)
{
BrowserData *data;
GError *error = NULL;
g_return_if_fail (GTH_IS_BROWSER (browser));
data = g_new0 (BrowserData, 1);
data->find_action = gtk_action_group_new ("Find Duplicates Action");
gtk_action_group_set_translation_domain (data->find_action, NULL);
gtk_action_group_add_actions (data->find_action,
find_action_entries,
find_action_entries_size,
browser);
gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->find_action, 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);
}
g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
g_action_map_add_action_entries (G_ACTION_MAP (browser),
actions,
G_N_ELEMENTS (actions),
browser);
gth_menu_manager_append_entries (gth_browser_get_menu_manager (browser, GTH_BROWSER_MENU_MANAGER_GEARS_FOLDER_ACTIONS),
action_entries,
G_N_ELEMENTS (action_entries));
}
......@@ -103,9 +103,9 @@ search__gth_browser_update_extra_widget_cb (GthBrowser *browser)
gtk_button_set_relief (GTK_BUTTON (data->refresh_button), GTK_RELIEF_NONE);
gtk_widget_set_tooltip_text (data->refresh_button, _("Search again"));
gtk_widget_show_all (data->refresh_button);
gedit_message_area_add_action_widget (GEDIT_MESSAGE_AREA (gth_browser_get_list_extra_widget (browser)),
data->refresh_button,
_RESPONSE_REFRESH);
gtk_info_bar_add_action_widget (GTK_INFO_BAR (gth_browser_get_list_extra_widget (browser)),
data->refresh_button,
_RESPONSE_REFRESH);
g_signal_connect (data->refresh_button,
"clicked",
G_CALLBACK (refresh_button_clicked_cb),
......
......@@ -270,15 +270,15 @@ browser_location_ready_cb (GthBrowser *browser,
gth_embedded_dialog_set_icon (GTH_EMBEDDED_DIALOG (task->priv->dialog), GTK_STOCK_FIND, GTK_ICON_SIZE_DIALOG);
gth_embedded_dialog_set_primary_text (GTH_EMBEDDED_DIALOG (task->priv->dialog), _("Searching..."));
update_secondary_text (task);
gedit_message_area_clear_action_area (GEDIT_MESSAGE_AREA (task->priv->dialog));
_gtk_info_bar_clear_action_area (GTK_INFO_BAR (task->priv->dialog));
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_stock (GTK_STOCK_STOP, GTK_ICON_SIZE_BUTTON));
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
gtk_widget_set_tooltip_text (button, _("Cancel the operation"));
gtk_widget_show_all (button);
gedit_message_area_add_action_widget (GEDIT_MESSAGE_AREA (task->priv->dialog),
button,
GTK_RESPONSE_CANCEL);
gtk_info_bar_add_action_widget (GTK_INFO_BAR (task->priv->dialog),
button,
GTK_RESPONSE_CANCEL);
dialog_data = g_new0 (EmbeddedDialogData, 1);
dialog_data->browser = task->priv->browser;
......
......@@ -11,8 +11,6 @@ MARSHALLERS = \
gth-marshal.h
EXTERNAL = \
gedit-message-area.c \
gedit-message-area.h \
gnome-desktop-thumbnail.c \
gnome-desktop-thumbnail.h \
gnome-thumbnail-pixbuf-utils.c
......@@ -27,7 +25,6 @@ PUBLIC_HEADER_FILES = \
cairo-utils.h \
color-utils.h \
dom.h \
gedit-message-area.h \
gfixed.h \
gio-utils.h \
glib-utils.h \
......
/*
* gedit-message-area.c
* This file is part of gedit
*
* Copyright (C) 2005 - Paolo Maggi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the gedit Team, 2005. See the AUTHORS file for a
* list of people on the gedit Team.
* See the ChangeLog files for a list of changes.
*
* $Id: gedit-message-area.c 6468 2008-08-28 08:23:00Z icq $
*/
/* TODO: Style properties */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include "gedit-message-area.h"
#include "gtk-utils.h"
#define GEDIT_MESSAGE_AREA_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
GEDIT_TYPE_MESSAGE_AREA, \
GeditMessageAreaPrivate))
struct _GeditMessageAreaPrivate
{
GtkWidget *main_hbox;
GtkWidget *contents;
GtkWidget *action_area;
gboolean changing_style;
};
typedef struct _ResponseData ResponseData;
struct _ResponseData
{
gint response_id;
};
enum {
RESPONSE,
CLOSE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE(GeditMessageArea, gedit_message_area, GTK_TYPE_BOX)
static ResponseData *
get_response_data (GtkWidget *widget,
gboolean create)
{
ResponseData *ad = g_object_get_data (G_OBJECT (widget),
"gedit-message-area-response-data");