Merge pull request #41 from JosephMcc/toolbar-revamp1

toolbar: Revamp the main toolbar style
This commit is contained in:
Clement Lefebvre 2016-10-07 11:22:16 +01:00 committed by GitHub
commit 9bf99cc84f
9 changed files with 188 additions and 262 deletions

View File

@ -111,11 +111,6 @@
<summary>Toolbar is Visible</summary> <summary>Toolbar is Visible</summary>
<description>Whether the toolbar should be visible in editing windows.</description> <description>Whether the toolbar should be visible in editing windows.</description>
</key> </key>
<key name="toolbar-buttons-style" type="s">
<default>'@TOOLBAR_STYLE@'</default>
<summary>Toolbar Buttons Style</summary>
<description>Style for the toolbar buttons. Possible values are "XED_TOOLBAR_SYSTEM" to use the system's default style, "XED_TOOLBAR_ICONS" to display icons only, "XED_TOOLBAR_ICONS_AND_TEXT" to display both icons and text, and "XED_TOOLBAR_ICONS_BOTH_HORIZ" to display prioritized text beside icons. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
</key>
<key name="statusbar-visible" type="b"> <key name="statusbar-visible" type="b">
<default>true</default> <default>true</default>
<summary>Status Bar is Visible</summary> <summary>Status Bar is Visible</summary>

View File

@ -84,7 +84,7 @@ static void sort_real (SortDialog *dialog);
static const GtkActionEntry action_entries[] = static const GtkActionEntry action_entries[] =
{ {
{ "Sort", { "Sort",
GTK_STOCK_SORT_ASCENDING, "view-sort-ascending-symbolic",
N_("S_ort..."), N_("S_ort..."),
NULL, NULL,
N_("Sort the current document or selection"), N_("Sort the current document or selection"),

View File

@ -88,7 +88,7 @@ static void auto_spell_cb (GtkAction *action, XedWindow *window);
static const GtkActionEntry action_entries[] = static const GtkActionEntry action_entries[] =
{ {
{ "CheckSpell", { "CheckSpell",
GTK_STOCK_SPELL_CHECK, "tools-check-spelling-symbolic",
N_("_Check Spelling..."), N_("_Check Spelling..."),
"<shift>F7", "<shift>F7",
N_("Check the current document for incorrect spelling"), N_("Check the current document for incorrect spelling"),

View File

@ -1316,8 +1316,8 @@ xed_prefs_manager_source_style_scheme_changed (GSettings *settings,
static void static void
xed_prefs_manager_max_recents_changed (GSettings *settings, xed_prefs_manager_max_recents_changed (GSettings *settings,
gchar *key, gchar *key,
gpointer user_data) gpointer user_data)
{ {
xed_debug (DEBUG_PREFS); xed_debug (DEBUG_PREFS);
@ -1328,21 +1328,11 @@ xed_prefs_manager_max_recents_changed (GSettings *settings,
max = g_settings_get_int (settings, key); max = g_settings_get_int (settings, key);
if (max < 0) { if (max < 0)
{
max = GPM_DEFAULT_MAX_RECENTS; max = GPM_DEFAULT_MAX_RECENTS;
} }
windows = xed_app_get_windows (xed_app_get_default ());
while (windows != NULL)
{
XedWindow *w = windows->data;
gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (w->priv->toolbar_recent_menu),
max);
windows = g_list_next (windows);
}
/* FIXME: we have no way at the moment to trigger the /* FIXME: we have no way at the moment to trigger the
* update of the inline recents in the File menu */ * update of the inline recents in the File menu */
} }

View File

@ -359,76 +359,6 @@ DEFINE_BOOL_PREF (display_line_numbers,
DEFINE_BOOL_PREF (toolbar_visible, DEFINE_BOOL_PREF (toolbar_visible,
GPM_TOOLBAR_VISIBLE) GPM_TOOLBAR_VISIBLE)
/* Toolbar suttons style */
XedToolbarSetting
xed_prefs_manager_get_toolbar_buttons_style (void)
{
gchar *str;
XedToolbarSetting res;
xed_debug (DEBUG_PREFS);
str = xed_prefs_manager_get_string (GPM_TOOLBAR_BUTTONS_STYLE);
if (strcmp (str, "XED_TOOLBAR_ICONS") == 0)
res = XED_TOOLBAR_ICONS;
else
{
if (strcmp (str, "XED_TOOLBAR_ICONS_AND_TEXT") == 0)
res = XED_TOOLBAR_ICONS_AND_TEXT;
else
{
if (strcmp (str, "XED_TOOLBAR_ICONS_BOTH_HORIZ") == 0)
res = XED_TOOLBAR_ICONS_BOTH_HORIZ;
else
res = XED_TOOLBAR_SYSTEM;
}
}
g_free (str);
return res;
}
void
xed_prefs_manager_set_toolbar_buttons_style (XedToolbarSetting tbs)
{
const gchar * str;
xed_debug (DEBUG_PREFS);
switch (tbs)
{
case XED_TOOLBAR_ICONS:
str = "XED_TOOLBAR_ICONS";
break;
case XED_TOOLBAR_ICONS_AND_TEXT:
str = "XED_TOOLBAR_ICONS_AND_TEXT";
break;
case XED_TOOLBAR_ICONS_BOTH_HORIZ:
str = "XED_TOOLBAR_ICONS_BOTH_HORIZ";
break;
default: /* XED_TOOLBAR_SYSTEM */
str = "XED_TOOLBAR_SYSTEM";
}
xed_prefs_manager_set_string (GPM_TOOLBAR_BUTTONS_STYLE,
str);
}
gboolean
xed_prefs_manager_toolbar_buttons_style_can_set (void)
{
xed_debug (DEBUG_PREFS);
return xed_prefs_manager_key_is_writable (GPM_TOOLBAR_BUTTONS_STYLE);
}
/* Statusbar visiblity */ /* Statusbar visiblity */
DEFINE_BOOL_PREF (statusbar_visible, DEFINE_BOOL_PREF (statusbar_visible,
GPM_STATUSBAR_VISIBLE) GPM_STATUSBAR_VISIBLE)

View File

@ -74,7 +74,6 @@
/* UI */ /* UI */
#define GPM_TOOLBAR_VISIBLE "toolbar-visible" #define GPM_TOOLBAR_VISIBLE "toolbar-visible"
#define GPM_TOOLBAR_BUTTONS_STYLE "toolbar-buttons-style"
#define GPM_STATUSBAR_VISIBLE "statusbar-visible" #define GPM_STATUSBAR_VISIBLE "statusbar-visible"
@ -115,13 +114,6 @@
#define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */ #define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */
#define GPM_DEFAULT_MAX_RECENTS 5 #define GPM_DEFAULT_MAX_RECENTS 5
typedef enum {
XED_TOOLBAR_SYSTEM = 0,
XED_TOOLBAR_ICONS,
XED_TOOLBAR_ICONS_AND_TEXT,
XED_TOOLBAR_ICONS_BOTH_HORIZ
} XedToolbarSetting;
/** LIFE CYCLE MANAGEMENT FUNCTIONS **/ /** LIFE CYCLE MANAGEMENT FUNCTIONS **/
gboolean xed_prefs_manager_init (void); gboolean xed_prefs_manager_init (void);
@ -195,11 +187,6 @@ gboolean xed_prefs_manager_get_toolbar_visible (void);
void xed_prefs_manager_set_toolbar_visible (gboolean tv); void xed_prefs_manager_set_toolbar_visible (gboolean tv);
gboolean xed_prefs_manager_toolbar_visible_can_set (void); gboolean xed_prefs_manager_toolbar_visible_can_set (void);
/* Toolbar buttons style */
XedToolbarSetting xed_prefs_manager_get_toolbar_buttons_style (void);
void xed_prefs_manager_set_toolbar_buttons_style (XedToolbarSetting tbs);
gboolean xed_prefs_manager_toolbar_buttons_style_can_set (void);
/* Statusbar visible */ /* Statusbar visible */
gboolean xed_prefs_manager_get_statusbar_visible (void); gboolean xed_prefs_manager_get_statusbar_visible (void);
void xed_prefs_manager_set_statusbar_visible (gboolean sv); void xed_prefs_manager_set_statusbar_visible (gboolean sv);

View File

@ -53,23 +53,23 @@ static const GtkActionEntry xed_always_sensitive_menu_entries[] =
{ "Help", NULL, N_("_Help") }, { "Help", NULL, N_("_Help") },
/* File menu */ /* File menu */
{ "FileNew", GTK_STOCK_NEW, NULL, "<control>N", { "FileNew", "document-new-symbolic", N_("_New"), "<control>N",
N_("Create a new document"), G_CALLBACK (_xed_cmd_file_new) }, N_("Create a new document"), G_CALLBACK (_xed_cmd_file_new) },
{ "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O", { "FileOpen", "document-open-symbolic", N_("_Open..."), "<control>O",
N_("Open a file"), G_CALLBACK (_xed_cmd_file_open) }, N_("Open a file"), G_CALLBACK (_xed_cmd_file_open) },
/* Edit menu */ /* Edit menu */
{ "EditPreferences", GTK_STOCK_PREFERENCES, N_("Pr_eferences"), NULL, { "EditPreferences", "preferences-other-symbolic", N_("Pr_eferences"), NULL,
N_("Configure the application"), G_CALLBACK (_xed_cmd_edit_preferences) }, N_("Configure the application"), G_CALLBACK (_xed_cmd_edit_preferences) },
/* Help menu */ /* Help menu */
{"HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", {"HelpContents", "help-contents-symbolic", N_("_Contents"), "F1",
N_("Open the xed manual"), G_CALLBACK (_xed_cmd_help_contents) }, N_("Open the xed manual"), G_CALLBACK (_xed_cmd_help_contents) },
{ "HelpAbout", GTK_STOCK_ABOUT, NULL, NULL, { "HelpAbout", "help-about-symbolic", N_("About"), NULL,
N_("About this application"), G_CALLBACK (_xed_cmd_help_about) }, N_("About this application"), G_CALLBACK (_xed_cmd_help_about) },
/* Fullscreen toolbar */ /* Fullscreen toolbar */
{ "LeaveFullscreen", GTK_STOCK_LEAVE_FULLSCREEN, NULL, { "LeaveFullscreen", "view-restore-symbolic", NULL,
NULL, N_("Leave fullscreen mode"), NULL, N_("Leave fullscreen mode"),
G_CALLBACK (_xed_cmd_view_leave_fullscreen_mode) } G_CALLBACK (_xed_cmd_view_leave_fullscreen_mode) }
}; };
@ -77,52 +77,52 @@ static const GtkActionEntry xed_always_sensitive_menu_entries[] =
static const GtkActionEntry xed_menu_entries[] = static const GtkActionEntry xed_menu_entries[] =
{ {
/* File menu */ /* File menu */
{ "FileSave", GTK_STOCK_SAVE, NULL, "<control>S", { "FileSave", "document-save-symbolic", N_("_Save"), "<control>S",
N_("Save the current file"), G_CALLBACK (_xed_cmd_file_save) }, N_("Save the current file"), G_CALLBACK (_xed_cmd_file_save) },
{ "FileSaveAs", GTK_STOCK_SAVE_AS, N_("Save _As..."), "<shift><control>S", { "FileSaveAs", "document-save-as-symbolic", N_("Save _As..."), "<shift><control>S",
N_("Save the current file with a different name"), G_CALLBACK (_xed_cmd_file_save_as) }, N_("Save the current file with a different name"), G_CALLBACK (_xed_cmd_file_save_as) },
{ "FileRevert", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL, { "FileRevert", "document-revert-symbolic", N_("Revert"), NULL,
N_("Revert to a saved version of the file"), G_CALLBACK (_xed_cmd_file_revert) }, N_("Revert to a saved version of the file"), G_CALLBACK (_xed_cmd_file_revert) },
{ "FilePrintPreview", GTK_STOCK_PRINT_PREVIEW, N_("Print Previe_w"),"<control><shift>P", { "FilePrintPreview", "document-print-preview-symbolic", N_("Print Previe_w"),"<control><shift>P",
N_("Print preview"), G_CALLBACK (_xed_cmd_file_print_preview) }, N_("Print preview"), G_CALLBACK (_xed_cmd_file_print_preview) },
{ "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P", { "FilePrint", "document-print-symbolic", N_("_Print..."), "<control>P",
N_("Print the current page"), G_CALLBACK (_xed_cmd_file_print) }, N_("Print the current page"), G_CALLBACK (_xed_cmd_file_print) },
/* Edit menu */ /* Edit menu */
{ "EditUndo", GTK_STOCK_UNDO, NULL, "<control>Z", { "EditUndo", "edit-undo-symbolic", N_("Undo"), "<control>Z",
N_("Undo the last action"), G_CALLBACK (_xed_cmd_edit_undo) }, N_("Undo the last action"), G_CALLBACK (_xed_cmd_edit_undo) },
{ "EditRedo", GTK_STOCK_REDO, NULL, "<control>Y", { "EditRedo", "edit-redo-symbolic", N_("Redo"), "<control>Y",
N_("Redo the last undone action"), G_CALLBACK (_xed_cmd_edit_redo) }, N_("Redo the last undone action"), G_CALLBACK (_xed_cmd_edit_redo) },
{ "EditCut", GTK_STOCK_CUT, NULL, "<control>X", { "EditCut", "edit-cut-symbolic", N_("Cut"), "<control>X",
N_("Cut the selection"), G_CALLBACK (_xed_cmd_edit_cut) }, N_("Cut the selection"), G_CALLBACK (_xed_cmd_edit_cut) },
{ "EditCopy", GTK_STOCK_COPY, NULL, "<control>C", { "EditCopy", "edit-copy-symbolic", N_("Copy"), "<control>C",
N_("Copy the selection"), G_CALLBACK (_xed_cmd_edit_copy) }, N_("Copy the selection"), G_CALLBACK (_xed_cmd_edit_copy) },
{ "EditPaste", GTK_STOCK_PASTE, NULL, "<control>V", { "EditPaste", "edit-paste-symbolic", N_("Paste"), "<control>V",
N_("Paste the clipboard"), G_CALLBACK (_xed_cmd_edit_paste) }, N_("Paste the clipboard"), G_CALLBACK (_xed_cmd_edit_paste) },
{ "EditDelete", GTK_STOCK_DELETE, NULL, NULL, { "EditDelete", "edit-delete-symbolic", N_("Delete"), NULL,
N_("Delete the selected text"), G_CALLBACK (_xed_cmd_edit_delete) }, N_("Delete the selected text"), G_CALLBACK (_xed_cmd_edit_delete) },
{ "EditSelectAll", GTK_STOCK_SELECT_ALL, N_("Select _All"), "<control>A", { "EditSelectAll", "edit-select-all-symbolic", N_("Select _All"), "<control>A",
N_("Select the entire document"), G_CALLBACK (_xed_cmd_edit_select_all) }, N_("Select the entire document"), G_CALLBACK (_xed_cmd_edit_select_all) },
/* View menu */ /* View menu */
{ "ViewHighlightMode", NULL, N_("_Highlight Mode") }, { "ViewHighlightMode", NULL, N_("_Highlight Mode") },
/* Search menu */ /* Search menu */
{ "SearchFind", GTK_STOCK_FIND, N_("_Find..."), "<control>F", { "SearchFind", "edit-find-symbolic", N_("_Find"), "<control>F",
N_("Search for text"), G_CALLBACK (_xed_cmd_search_find) }, N_("Search for text"), G_CALLBACK (_xed_cmd_search_find) },
{ "SearchFindNext", NULL, N_("Find Ne_xt"), "<control>G", { "SearchFindNext", NULL, N_("Find Ne_xt"), "<control>G",
N_("Search forwards for the same text"), G_CALLBACK (_xed_cmd_search_find_next) }, N_("Search forwards for the same text"), G_CALLBACK (_xed_cmd_search_find_next) },
{ "SearchFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G", { "SearchFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G",
N_("Search backwards for the same text"), G_CALLBACK (_xed_cmd_search_find_prev) }, N_("Search backwards for the same text"), G_CALLBACK (_xed_cmd_search_find_prev) },
{ "SearchReplace", GTK_STOCK_FIND_AND_REPLACE, N_("_Replace..."), "<control>H", { "SearchReplace", "edit-find-replace-symbolic", N_("_Replace"), "<control>H",
N_("Search for and replace text"), G_CALLBACK (_xed_cmd_search_replace) }, N_("Search for and replace text"), G_CALLBACK (_xed_cmd_search_replace) },
{ "SearchGoToLine", GTK_STOCK_JUMP_TO, N_("Go to _Line..."), "<control>I", { "SearchGoToLine", "go-jump-symbolic", N_("Go to _Line..."), "<control>I",
N_("Go to a specific line"), G_CALLBACK (_xed_cmd_search_goto_line) }, N_("Go to a specific line"), G_CALLBACK (_xed_cmd_search_goto_line) },
/* Documents menu */ /* Documents menu */
{ "FileSaveAll", GTK_STOCK_SAVE, N_("_Save All"), "<shift><control>L", { "FileSaveAll", "document-save-symbolic", N_("_Save All"), "<shift><control>L",
N_("Save all open files"), G_CALLBACK (_xed_cmd_file_save_all) }, N_("Save all open files"), G_CALLBACK (_xed_cmd_file_save_all) },
{ "FileCloseAll", GTK_STOCK_CLOSE, N_("_Close All"), "<shift><control>W", { "FileCloseAll", "window-close-symbolic", N_("_Close All"), "<shift><control>W",
N_("Close all open files"), G_CALLBACK (_xed_cmd_file_close_all) }, N_("Close all open files"), G_CALLBACK (_xed_cmd_file_close_all) },
{ "DocumentsPreviousDocument", NULL, N_("_Previous Document"), "<alt><control>Page_Up", { "DocumentsPreviousDocument", NULL, N_("_Previous Document"), "<alt><control>Page_Up",
N_("Activate previous document"), G_CALLBACK (_xed_cmd_documents_previous_document) }, N_("Activate previous document"), G_CALLBACK (_xed_cmd_documents_previous_document) },
@ -135,14 +135,14 @@ static const GtkActionEntry xed_menu_entries[] =
/* separate group, needs to be sensitive on OS X even when there are no tabs */ /* separate group, needs to be sensitive on OS X even when there are no tabs */
static const GtkActionEntry xed_close_menu_entries[] = static const GtkActionEntry xed_close_menu_entries[] =
{ {
{ "FileClose", GTK_STOCK_CLOSE, NULL, "<control>W", { "FileClose", "window-close-symbolic", N_("_Close"), "<control>W",
N_("Close the current file"), G_CALLBACK (_xed_cmd_file_close) } N_("Close the current file"), G_CALLBACK (_xed_cmd_file_close) }
}; };
/* separate group, should be sensitive even when there are no tabs */ /* separate group, should be sensitive even when there are no tabs */
static const GtkActionEntry xed_quit_menu_entries[] = static const GtkActionEntry xed_quit_menu_entries[] =
{ {
{ "FileQuit", GTK_STOCK_QUIT, NULL, "<control>Q", { "FileQuit", "application-exit-symbolic", N_("_Quit"), "<control>Q",
N_("Quit the program"), G_CALLBACK (_xed_cmd_file_quit) } N_("Quit the program"), G_CALLBACK (_xed_cmd_file_quit) }
}; };

View File

@ -56,6 +56,7 @@ struct _XedWindowPrivate
/* Widgets for fullscreen mode */ /* Widgets for fullscreen mode */
GtkWidget *fullscreen_controls; GtkWidget *fullscreen_controls;
GtkWidget *fullscreen_controls_container;
guint fullscreen_animation_timeout_id; guint fullscreen_animation_timeout_id;
gboolean fullscreen_animation_enter; gboolean fullscreen_animation_enter;
@ -79,9 +80,7 @@ struct _XedWindowPrivate
GtkActionGroup *documents_list_action_group; GtkActionGroup *documents_list_action_group;
guint documents_list_menu_ui_id; guint documents_list_menu_ui_id;
GtkWidget *toolbar; GtkWidget *toolbar;
GtkWidget *toolbar_recent_menu;
GtkWidget *menubar; GtkWidget *menubar;
XedToolbarSetting toolbar_style;
/* recent files */ /* recent files */
GtkActionGroup *recents_action_group; GtkActionGroup *recents_action_group;

View File

@ -393,41 +393,12 @@ disconnect_proxy_cb (GtkUIManager *manager,
} }
} }
static void
apply_toolbar_style (XedWindow *window,
GtkWidget *toolbar)
{
switch (window->priv->toolbar_style)
{
case XED_TOOLBAR_SYSTEM:
xed_debug_message (DEBUG_WINDOW, "XED: SYSTEM");
gtk_toolbar_unset_style (GTK_TOOLBAR(toolbar));
break;
case XED_TOOLBAR_ICONS:
xed_debug_message (DEBUG_WINDOW, "XED: ICONS");
gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
break;
case XED_TOOLBAR_ICONS_AND_TEXT:
xed_debug_message (DEBUG_WINDOW, "XED: ICONS_AND_TEXT");
gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
break;
case XED_TOOLBAR_ICONS_BOTH_HORIZ:
xed_debug_message (DEBUG_WINDOW, "XED: ICONS_BOTH_HORIZ");
gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
break;
}
}
/* Returns TRUE if toolbar is visible */ /* Returns TRUE if toolbar is visible */
static gboolean static gboolean
set_toolbar_style (XedWindow *window, set_toolbar_style (XedWindow *window,
XedWindow *origin) XedWindow *origin)
{ {
gboolean visible; gboolean visible;
XedToolbarSetting style;
GtkAction *action; GtkAction *action;
if (origin == NULL) if (origin == NULL)
@ -456,20 +427,6 @@ set_toolbar_style (XedWindow *window,
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action), visible); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action), visible);
} }
/* Set style */
if (origin == NULL)
{
style = xed_prefs_manager_get_toolbar_buttons_style ();
}
else
{
style = origin->priv->toolbar_style;
}
window->priv->toolbar_style = style;
apply_toolbar_style (window, window->priv->toolbar);
return visible; return visible;
} }
@ -950,19 +907,6 @@ open_recent_file (const gchar *uri,
g_slist_free (uris); g_slist_free (uris);
} }
static void
recent_chooser_item_activated (GtkRecentChooser *chooser,
XedWindow *window)
{
gchar *uri;
uri = gtk_recent_chooser_get_current_uri (chooser);
open_recent_file (uri, window);
g_free (uri);
}
static void static void
recents_menu_activate (GtkAction *action, recents_menu_activate (GtkAction *action,
XedWindow *window) XedWindow *window)
@ -1116,13 +1060,6 @@ update_recent_files_menu (XedWindow *window)
g_list_free (items); g_list_free (items);
} }
static void
set_non_homogeneus (GtkWidget *widget,
gpointer data)
{
gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM(widget), FALSE);
}
static void static void
toolbar_visibility_changed (GtkWidget *toolbar, toolbar_visibility_changed (GtkWidget *toolbar,
XedWindow *window) XedWindow *window)
@ -1146,45 +1083,21 @@ toolbar_visibility_changed (GtkWidget *toolbar,
} }
static GtkWidget * static GtkWidget *
setup_toolbar_open_button (XedWindow *window, create_toolbar_button (GtkAction *action)
GtkWidget *toolbar)
{ {
GtkRecentManager *recent_manager; GtkWidget *button;
GtkRecentFilter *filter; GtkWidget *image;
GtkWidget *toolbar_recent_menu;
GtkToolItem *open_button;
GtkAction *action;
recent_manager = gtk_recent_manager_get_default (); button = gtk_button_new ();
image = gtk_image_new ();
/* recent files menu tool button */ gtk_button_set_image (GTK_BUTTON (button), image);
toolbar_recent_menu = gtk_recent_chooser_menu_new_for_manager (recent_manager); gtk_style_context_add_class (gtk_widget_get_style_context (button), "flat");
gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
gtk_button_set_label (GTK_BUTTON (button), NULL);
gtk_widget_set_tooltip_text (button, gtk_action_get_tooltip (action));
gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER(toolbar_recent_menu), return button;
FALSE);
gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER(toolbar_recent_menu), GTK_RECENT_SORT_MRU);
gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER(toolbar_recent_menu), xed_prefs_manager_get_max_recents ());
filter = gtk_recent_filter_new ();
gtk_recent_filter_add_group (filter, "xed");
gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER(toolbar_recent_menu), filter);
g_signal_connect(toolbar_recent_menu, "item_activated", G_CALLBACK (recent_chooser_item_activated), window);
/* add the custom Open button to the toolbar */
open_button = gtk_menu_tool_button_new_from_stock (GTK_STOCK_OPEN);
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON(open_button), toolbar_recent_menu);
gtk_tool_item_set_tooltip_text (open_button, _("Open a file"));
gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON(open_button), _("Open a recently used file"));
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "FileOpen");
g_object_set (action, "short_label", _("Open"), NULL);
gtk_activatable_set_related_action (GTK_ACTIVATABLE(open_button), action);
gtk_toolbar_insert (GTK_TOOLBAR(toolbar), open_button, 1);
return toolbar_recent_menu;
} }
static void static void
@ -1197,6 +1110,11 @@ create_menu_bar_and_toolbar (XedWindow *window,
GtkRecentManager *recent_manager; GtkRecentManager *recent_manager;
GError *error = NULL; GError *error = NULL;
gchar *ui_file; gchar *ui_file;
GtkWidget *tool_item;
GtkWidget *tool_box;
GtkWidget *box;
GtkWidget *separator;
GtkWidget *button;
xed_debug (DEBUG_WINDOW); xed_debug (DEBUG_WINDOW);
@ -1223,16 +1141,6 @@ create_menu_bar_and_toolbar (XedWindow *window,
g_object_unref (action_group); g_object_unref (action_group);
window->priv->action_group = action_group; window->priv->action_group = action_group;
/* set short labels to use in the toolbar */
action = gtk_action_group_get_action (action_group, "FileSave");
g_object_set (action, "short_label", _("Save"), NULL);
action = gtk_action_group_get_action (action_group, "FilePrint");
g_object_set (action, "short_label", _("Print"), NULL);
action = gtk_action_group_get_action (action_group, "SearchFind");
g_object_set (action, "short_label", _("Find"), NULL);
action = gtk_action_group_get_action (action_group, "SearchReplace");
g_object_set (action, "short_label", _("Replace"), NULL);
action_group = gtk_action_group_new ("XedQuitWindowActions"); action_group = gtk_action_group_new ("XedQuitWindowActions");
gtk_action_group_set_translation_domain (action_group, NULL); gtk_action_group_set_translation_domain (action_group, NULL);
gtk_action_group_add_actions (action_group, xed_quit_menu_entries, G_N_ELEMENTS(xed_quit_menu_entries), window); gtk_action_group_add_actions (action_group, xed_quit_menu_entries, G_N_ELEMENTS(xed_quit_menu_entries), window);
@ -1302,17 +1210,82 @@ create_menu_bar_and_toolbar (XedWindow *window,
window->priv->menubar = gtk_ui_manager_get_widget (manager, "/MenuBar"); window->priv->menubar = gtk_ui_manager_get_widget (manager, "/MenuBar");
gtk_box_pack_start (GTK_BOX(main_box), window->priv->menubar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(main_box), window->priv->menubar, FALSE, FALSE, 0);
window->priv->toolbar = gtk_ui_manager_get_widget (manager, "/ToolBar"); window->priv->toolbar = gtk_toolbar_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->toolbar), gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
gtk_box_pack_start (GTK_BOX(main_box), window->priv->toolbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(main_box), window->priv->toolbar, FALSE, FALSE, 0);
tool_item = gtk_tool_item_new ();
gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (window->priv->toolbar), GTK_TOOL_ITEM (tool_item), 0);
tool_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_add (GTK_CONTAINER (tool_item), tool_box);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (tool_box), box, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "FileNew");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "FileOpen");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "FileSave");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (tool_box), separator, FALSE, FALSE, 0);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (tool_box), box, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditUndo");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditRedo");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (tool_box), separator, FALSE, FALSE, 0);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (tool_box), box, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditCut");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditCopy");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditPaste");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (tool_box), separator, FALSE, FALSE, 0);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (tool_box), box, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "SearchFind");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "SearchReplace");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
gtk_widget_show_all (GTK_WIDGET (window->priv->toolbar));
set_toolbar_style (window, NULL); set_toolbar_style (window, NULL);
window->priv->toolbar_recent_menu = setup_toolbar_open_button (window, window->priv->toolbar);
gtk_container_foreach (GTK_CONTAINER(window->priv->toolbar), (GtkCallback) set_non_homogeneus, NULL);
g_signal_connect_after(G_OBJECT (window->priv->toolbar), "show", G_CALLBACK (toolbar_visibility_changed), window); g_signal_connect_after(G_OBJECT (window->priv->toolbar), "show", G_CALLBACK (toolbar_visibility_changed), window);
g_signal_connect_after(G_OBJECT (window->priv->toolbar), "hide", G_CALLBACK (toolbar_visibility_changed), window); g_signal_connect_after(G_OBJECT (window->priv->toolbar), "hide", G_CALLBACK (toolbar_visibility_changed), window);
} }
@ -2404,16 +2377,16 @@ fullscreen_controls_show (XedWindow *window)
{ {
GdkScreen *screen; GdkScreen *screen;
GdkRectangle fs_rect; GdkRectangle fs_rect;
gint w, h; gint min_h, nat_h;
screen = gtk_window_get_screen (GTK_WINDOW(window)); screen = gtk_window_get_screen (GTK_WINDOW (window));
gdk_screen_get_monitor_geometry ( gdk_screen_get_monitor_geometry (
screen, gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (GTK_WIDGET(window))), screen, gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (GTK_WIDGET(window))),
&fs_rect); &fs_rect);
gtk_window_get_size (GTK_WINDOW(window->priv->fullscreen_controls), &w, &h); gtk_widget_get_preferred_height (window->priv->fullscreen_controls_container, &min_h, &nat_h);
gtk_window_resize (GTK_WINDOW(window->priv->fullscreen_controls), fs_rect.width, h); gtk_window_resize (GTK_WINDOW (window->priv->fullscreen_controls), fs_rect.width, nat_h);
gtk_window_move (GTK_WINDOW(window->priv->fullscreen_controls), fs_rect.x, fs_rect.y - h + 1); gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls), fs_rect.x, fs_rect.y - nat_h + 1);
gtk_widget_show_all (window->priv->fullscreen_controls); gtk_widget_show_all (window->priv->fullscreen_controls);
} }
@ -2544,9 +2517,11 @@ static void
fullscreen_controls_build (XedWindow *window) fullscreen_controls_build (XedWindow *window)
{ {
XedWindowPrivate *priv = window->priv; XedWindowPrivate *priv = window->priv;
GtkWidget *toolbar;
GtkWidget *toolbar_recent_menu;
GtkAction *action; GtkAction *action;
GtkWidget *box;
GtkWidget *fullscreen_btn;
GtkWidget *separator;
GtkWidget *button;
if (priv->fullscreen_controls != NULL) if (priv->fullscreen_controls != NULL)
{ {
@ -2557,19 +2532,69 @@ fullscreen_controls_build (XedWindow *window)
gtk_window_set_transient_for (GTK_WINDOW(priv->fullscreen_controls), &window->window); gtk_window_set_transient_for (GTK_WINDOW(priv->fullscreen_controls), &window->window);
/* popup toolbar */ window->priv->fullscreen_controls_container = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
toolbar = gtk_ui_manager_get_widget (priv->manager, "/FullscreenToolBar"); gtk_container_set_border_width (GTK_CONTAINER (window->priv->fullscreen_controls_container), 6);
gtk_container_add (GTK_CONTAINER(priv->fullscreen_controls), toolbar); gtk_container_add (GTK_CONTAINER (priv->fullscreen_controls), window->priv->fullscreen_controls_container);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_vexpand (box, FALSE);
gtk_box_pack_start (GTK_BOX (window->priv->fullscreen_controls_container), box, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "FileNew");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group, "FileOpen");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "FileSave");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 6);
action = gtk_action_group_get_action (window->priv->action_group, "EditUndo");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditRedo");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 6);
action = gtk_action_group_get_action (window->priv->action_group, "EditCut");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditCopy");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "EditPaste");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 6);
action = gtk_action_group_get_action (window->priv->action_group, "SearchFind");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (window->priv->action_group, "SearchReplace");
button = create_toolbar_button (action);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
action = gtk_action_group_get_action (priv->always_sensitive_action_group, "LeaveFullscreen"); action = gtk_action_group_get_action (priv->always_sensitive_action_group, "LeaveFullscreen");
g_object_set (action, "is-important", TRUE, NULL); g_object_set (action, "is-important", TRUE, NULL);
fullscreen_btn = create_toolbar_button (action);
gtk_box_pack_end (GTK_BOX (box), fullscreen_btn, FALSE, FALSE, 0);
toolbar_recent_menu = setup_toolbar_open_button (window, toolbar); gtk_widget_show_all (window->priv->fullscreen_controls_container);
gtk_container_foreach (GTK_CONTAINER(toolbar), (GtkCallback) set_non_homogeneus, NULL);
/* Set the toolbar style */
gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
g_signal_connect(priv->fullscreen_controls, "enter-notify-event", g_signal_connect(priv->fullscreen_controls, "enter-notify-event",
G_CALLBACK (on_fullscreen_controls_enter_notify_event), window); G_CALLBACK (on_fullscreen_controls_enter_notify_event), window);