[geany/geany] 402d27: Persist colour picker palette

Matthew Brush git-noreply at xxxxx
Sat Oct 3 18:58:10 UTC 2020


Branch:      refs/heads/master
Author:      Matthew Brush <matt at geany.org>
Committer:   Matthew Brush <mbrush at codebrainz.ca>
Date:        Sat, 03 Oct 2020 18:58:10 UTC
Commit:      402d277f80b508e89440fe3669ce3f2f45768cc7
             https://github.com/geany/geany/commit/402d277f80b508e89440fe3669ce3f2f45768cc7

Log Message:
-----------
Persist colour picker palette

Closes #2595


Modified Paths:
--------------
    src/keyfile.c
    src/libmain.c
    src/tools.c
    src/ui_utils.h

Modified: src/keyfile.c
10 lines changed, 10 insertions(+), 0 deletions(-)
===================================================================
@@ -582,6 +582,7 @@ static void save_ui_prefs(GKeyFile *config)
 	g_key_file_set_boolean(config, PACKAGE, "statusbar_visible", interface_prefs.statusbar_visible);
 	g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", ui_prefs.msgwindow_visible);
 	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);
 
 	/* get the text from the scribble textview */
 	{
@@ -1027,6 +1028,15 @@ static void load_ui_prefs(GKeyFile *config)
 	ui_prefs.custom_date_format = utils_get_setting_string(config, PACKAGE, "custom_date_format", "");
 	ui_prefs.custom_commands = g_key_file_get_string_list(config, PACKAGE, "custom_commands", NULL, NULL);
 	ui_prefs.custom_commands_labels = g_key_file_get_string_list(config, PACKAGE, "custom_commands_labels", NULL, NULL);
+	ui_prefs.color_picker_palette = utils_get_setting_string(config, PACKAGE, "color_picker_palette", "");
+
+	/* Load the saved color picker palette */
+	if (!EMPTY(ui_prefs.color_picker_palette))
+	{
+		GtkSettings *settings;
+		settings = gtk_settings_get_for_screen(gtk_window_get_screen(GTK_WINDOW(main_widgets.window)));
+		g_object_set(G_OBJECT(settings), "gtk-color-palette", ui_prefs.color_picker_palette, NULL);
+	}
 
 	/* sanitize custom commands labels */
 	if (ui_prefs.custom_commands || ui_prefs.custom_commands_labels)


Modified: src/libmain.c
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -1368,6 +1368,7 @@ static gboolean do_main_quit(void)
 	g_free(prefs.default_open_path);
 	g_free(prefs.custom_plugin_path);
 	g_free(ui_prefs.custom_date_format);
+	g_free(ui_prefs.color_picker_palette);
 	g_free(interface_prefs.editor_font);
 	g_free(interface_prefs.tagbar_font);
 	g_free(interface_prefs.msgwin_font);


Modified: src/tools.c
15 lines changed, 15 insertions(+), 0 deletions(-)
===================================================================
@@ -812,6 +812,20 @@ static void on_color_dialog_response(GtkDialog *dialog, gint response, gpointer
 }
 
 
+static void on_color_selection_change_palette_with_screen(GdkScreen *screen, const GdkColor *colors, gint n_colors)
+{
+	GtkSettings *settings;
+
+	/* Get the updated palette */
+	g_free(ui_prefs.color_picker_palette);
+	ui_prefs.color_picker_palette = gtk_color_selection_palette_to_string(colors, n_colors);
+
+	/* Update the gtk-color-palette setting so all GtkColorSelection widgets will be modified */
+	settings = gtk_settings_get_for_screen(screen);
+	g_object_set(G_OBJECT(settings), "gtk-color-palette", ui_prefs.color_picker_palette, NULL);
+}
+
+
 /* This shows the color selection dialog to choose a color. */
 void tools_color_chooser(const gchar *color)
 {
@@ -836,6 +850,7 @@ void tools_color_chooser(const gchar *color)
 		gtk_window_set_transient_for(GTK_WINDOW(ui_widgets.open_colorsel), GTK_WINDOW(main_widgets.window));
 		colorsel = gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(ui_widgets.open_colorsel));
 		gtk_color_selection_set_has_palette(GTK_COLOR_SELECTION(colorsel), TRUE);
+		gtk_color_selection_set_change_palette_with_screen_hook(on_color_selection_change_palette_with_screen);
 
 		g_signal_connect(ui_widgets.open_colorsel, "response",
 						G_CALLBACK(on_color_dialog_response), NULL);


Modified: src/ui_utils.h
3 lines changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -172,6 +172,9 @@ typedef struct UIPrefs
 	gchar		*custom_date_format;
 	gchar		**custom_commands;
 	gchar		**custom_commands_labels;
+
+	/* Color picker settings */
+	gchar		*color_picker_palette;
 }
 UIPrefs;
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list