static void profile_palette_notify_colorpickers_cb (TerminalProfile *profile, GParamSpec *pspec, GtkWidget *editor) { GtkWidget *w; GdkColor colors[TERMINAL_PALETTE_SIZE]; guint n_colors, i; n_colors = G_N_ELEMENTS (colors); terminal_profile_get_palette (profile, colors, &n_colors); n_colors = MIN (n_colors, TERMINAL_PALETTE_SIZE); for (i = 0; i < n_colors; i++) { char name[32]; GdkColor old_color; g_snprintf (name, sizeof (name), "palette-colorpicker-%d", i + 1); w = profile_editor_get_widget (editor, name); gtk_color_button_get_color (GTK_COLOR_BUTTON (w), &old_color); if (!gdk_color_equal (&old_color, &colors[i])) { g_signal_handlers_block_by_func (w, G_CALLBACK (palette_color_notify_cb), profile); gtk_color_button_set_color (GTK_COLOR_BUTTON (w), &colors[i]); g_signal_handlers_unblock_by_func (w, G_CALLBACK (palette_color_notify_cb), profile); } } }
gboolean terminal_profile_get_palette_is_builtin (TerminalProfile *profile, guint *n) { GdkColor colors[TERMINAL_PALETTE_SIZE]; guint n_colors; guint i; n_colors = G_N_ELEMENTS (colors); if (!terminal_profile_get_palette (profile, colors, &n_colors) || n_colors != TERMINAL_PALETTE_SIZE) return FALSE; for (i = 0; i < TERMINAL_PALETTE_N_BUILTINS; ++i) if (palette_cmp (colors, terminal_palettes[i])) { *n = i; return TRUE; } return FALSE; }