Skip to content

Commit

Permalink
Save and restore menubar state
Browse files Browse the repository at this point in the history
  • Loading branch information
xiota committed Oct 30, 2021
1 parent 7a8818d commit a4e9d44
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/keyfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,13 @@ static void save_ui_prefs(GKeyFile *config)
g_key_file_set_boolean(config, PACKAGE, "fullscreen", ui_prefs.fullscreen);
g_key_file_set_string(config, PACKAGE, "color_picker_palette", ui_prefs.color_picker_palette);

/* Update and save current menubar state */
{
GtkWidget *geany_menubar = ui_lookup_widget(main_widgets.window, "hbox_menubar");
ui_prefs.menubar_visible = gtk_widget_is_visible(geany_menubar);
g_key_file_set_boolean(config, PACKAGE, "menubar_visible", ui_prefs.menubar_visible);
}

/* get the text from the scribble textview */
{
GtkTextBuffer *buffer;
Expand Down Expand Up @@ -1022,6 +1029,7 @@ static void load_ui_prefs(GKeyFile *config)
gint *geo;
gsize geo_len;

ui_prefs.menubar_visible = utils_get_setting_boolean(config, PACKAGE, "menubar_visible", TRUE);
ui_prefs.sidebar_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_visible", TRUE);
ui_prefs.msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
ui_prefs.fullscreen = utils_get_setting_boolean(config, PACKAGE, "fullscreen", FALSE);
Expand Down
4 changes: 2 additions & 2 deletions src/libmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,8 @@ gint main_lib(gint argc, gchar **argv)
gtk_widget_show(main_widgets.window);
main_status.main_window_realized = TRUE;

/* hide menubar */
if (interface_prefs.on_startup_hide_menubar)
/* restore menubar state or hide on startup */
if (!ui_prefs.menubar_visible || interface_prefs.on_startup_hide_menubar)
keybindings_send_command(GEANY_KEY_GROUP_VIEW, GEANY_KEYS_TOGGLE_MENUBAR);

configuration_apply_settings();
Expand Down
1 change: 1 addition & 0 deletions src/ui_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ typedef struct UIPrefs
gboolean sidebar_visible;
gint sidebar_page;
gboolean msgwindow_visible;
gboolean menubar_visible;
gboolean allow_always_save; /* if set, files can always be saved, even if unchanged */
gchar *statusbar_template;
gboolean new_document_after_close;
Expand Down

0 comments on commit a4e9d44

Please sign in to comment.