Use highlight dialog instead submenu in "View" menu.

This commit is contained in:
Tomasz Gąsior 2018-07-21 22:34:26 +02:00
parent d4de361efb
commit bc381189c7
6 changed files with 46 additions and 34 deletions

View File

@ -60,10 +60,7 @@
<separator/>
<placeholder name="ViewOps_1" />
<separator/>
<menu name="ViewHighlightModeMenu" action="ViewHighlightMode">
<placeholder name="LanguagesMenuPlaceholder">
</placeholder>
</menu>
<menuitem name="ViewHighlightModeMenu" action="ViewHighlightMode"/>
</menu>
<menu name="SearchMenu" action="Search">

View File

@ -42,6 +42,8 @@
#include "xed-window-private.h"
#include "xed-paned.h"
#include "xed-view-frame.h"
#include "xed-highlight-mode-dialog.h"
#include "xed-highlight-mode-selector.h"
void
_xed_cmd_view_show_toolbar (GtkAction *action,
@ -213,3 +215,41 @@ _xed_cmd_view_leave_fullscreen_mode (GtkAction *action,
_xed_window_unfullscreen (window);
g_signal_handlers_unblock_by_func (view_action, G_CALLBACK (_xed_cmd_view_toggle_fullscreen_mode), window);
}
static void
on_language_selected (XedHighlightModeSelector *sel,
GtkSourceLanguage *language,
XedWindow *window)
{
XedDocument *doc;
doc = xed_window_get_active_document (window);
if (doc)
{
xed_document_set_language (doc, language);
}
}
void
_xed_cmd_view_change_highlight_mode (GtkAction *action,
XedWindow *window)
{
GtkWidget *dlg;
XedHighlightModeSelector *sel;
XedDocument *doc;
dlg = xed_highlight_mode_dialog_new (GTK_WINDOW (window));
sel = xed_highlight_mode_dialog_get_selector (XED_HIGHLIGHT_MODE_DIALOG (dlg));
doc = xed_window_get_active_document (XED_WINDOW (window));
if (doc)
{
xed_highlight_mode_selector_select_language (sel,
xed_document_get_language (doc));
}
g_signal_connect (sel, "language-selected",
G_CALLBACK (on_language_selected), window);
gtk_widget_show (GTK_WIDGET (dlg));
}

View File

@ -51,6 +51,7 @@ void _xed_cmd_view_toggle_overview_map (GtkAction *action, XedWindow *window);
void _xed_cmd_view_toggle_fullscreen_mode (GtkAction *action, XedWindow *window);
void _xed_cmd_view_toggle_word_wrap (GtkAction *action, XedWindow *window);
void _xed_cmd_view_leave_fullscreen_mode (GtkAction *action, XedWindow *window);
void _xed_cmd_view_change_highlight_mode (GtkAction *action, XedWindow *window);
void _xed_cmd_search_find (GtkAction *action, XedWindow *window);

View File

@ -287,7 +287,7 @@ on_syntax_highlighting_changed (GSettings *settings,
const gchar *key,
XedSettings *xs)
{
GList *docs, *windows, *l;
GList *docs, *l;
gboolean enable;
enable = g_settings_get_boolean (settings, key);
@ -300,22 +300,6 @@ on_syntax_highlighting_changed (GSettings *settings,
}
g_list_free (docs);
/* update the sensitivity of the Higlight Mode menu item */
windows = xed_app_get_main_windows (XED_APP (g_application_get_default ()));
for (l = windows; l != NULL; l = g_list_next (l))
{
GtkUIManager *ui;
GtkAction *a;
ui = xed_window_get_ui_manager (XED_WINDOW (l->data));
a = gtk_ui_manager_get_action (ui, "/MenuBar/ViewMenu/ViewHighlightModeMenu");
gtk_action_set_sensitive (a, enable);
}
g_list_free (windows);
}
static void

View File

@ -107,7 +107,9 @@ static const GtkActionEntry xed_menu_entries[] =
N_("Select the entire document"), G_CALLBACK (_xed_cmd_edit_select_all) },
/* View menu */
{ "ViewHighlightMode", NULL, N_("_Highlight Mode") },
{ "ViewHighlightMode", NULL, N_("_Highlight Mode"), NULL,
N_("Change syntax hightlight mode"),
G_CALLBACK (_xed_cmd_view_change_highlight_mode), TRUE },
/* Search menu */
{ "SearchFind", "edit-find-symbolic", N_("_Find"), "<control>F",

View File

@ -1282,14 +1282,6 @@ create_menu_bar_and_toolbar (XedWindow *window,
window);
update_recent_files_menu (window);
/* languages menu */
action_group = gtk_action_group_new ("LanguagesActions");
gtk_action_group_set_translation_domain (action_group, NULL);
window->priv->languages_action_group = action_group;
gtk_ui_manager_insert_action_group (manager, action_group, 0);
g_object_unref (action_group);
create_languages_menu (window);
/* list of open documents menu */
action_group = gtk_action_group_new ("DocumentsListActions");
gtk_action_group_set_translation_domain (action_group, NULL);
@ -2254,9 +2246,6 @@ notebook_switch_page (GtkNotebook *book,
g_free (action_name);
/* update the syntax menu */
update_languages_menu (window);
view = xed_tab_get_view (tab);
map_frame = xed_view_frame_get_map_frame (XED_VIEW_FRAME (_xed_tab_get_view_frame (tab)));
@ -2846,7 +2835,6 @@ sync_languages_menu (XedDocument *doc,
GParamSpec *pspec,
XedWindow *window)
{
update_languages_menu (window);
peas_extension_set_call (window->priv->extensions, "update_state");
}