From bca17d1fdc0625e8fd739dcba9508c27eaae2a28 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Tue, 27 Apr 2004 21:42:47 +0000 Subject: i2004-04-27 Larry Ewing * gui/dialogs/calendar-setup.c (new_calendar_test_uri): add handler for test button. (calendar_setup_new_calendar): connect test button, fill in color picker member. (source_to_dialog): set the color picker color if the source has one. (dialog_to_source): set the source color. svn path=/trunk/; revision=25643 --- calendar/gui/dialogs/calendar-setup.c | 54 ++++++++++++++++++++++++++++++- calendar/gui/dialogs/calendar-setup.glade | 42 +++++++++++++----------- 2 files changed, 76 insertions(+), 20 deletions(-) (limited to 'calendar/gui') diff --git a/calendar/gui/dialogs/calendar-setup.c b/calendar/gui/dialogs/calendar-setup.c index c5da074f4b..93270fea48 100644 --- a/calendar/gui/dialogs/calendar-setup.c +++ b/calendar/gui/dialogs/calendar-setup.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ typedef struct /* General page fields */ GtkWidget *name_entry; + GtkWidget *source_color; /* Location page fields */ GtkWidget *uri_entry; @@ -370,6 +372,29 @@ general_update_dialog (SourceDialog *source_dialog) 0, 0, NULL, NULL, source_dialog); } +static void +colorpicker_set_color (GnomeColorPicker *color, guint32 rgb) +{ + gnome_color_picker_set_i8 (color, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff); +} + +static guint32 +colorpicker_get_color (GnomeColorPicker *color) +{ + guint8 r, g, b, a; + guint32 rgb = 0; + + gnome_color_picker_get_i8 (color, &r, &g, &b, &a); + + rgb = r; + rgb <<= 8; + rgb |= g; + rgb <<= 8; + rgb |= b; + + return rgb; +} + static void source_to_dialog (SourceDialog *source_dialog) { @@ -419,6 +444,16 @@ source_to_dialog (SourceDialog *source_dialog) if (source_dialog->refresh_spin) g_signal_handlers_unblock_matched (source_dialog->refresh_spin, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, source_dialog); + if (source_dialog->source_color) { + guint32 color = 0xff00ff00; + + if (source_dialog->source) + e_source_get_color (source_dialog->source, &color); + else + /* FIXME */; + + colorpicker_set_color (GNOME_COLOR_PICKER (source_dialog->source_color), color); + } } static void @@ -452,6 +487,10 @@ dialog_to_source (SourceDialog *source_dialog) e_source_set_property (source, "refresh", refresh_str); g_free (refresh_str); } + + if (source_dialog->source_color) + e_source_set_color (source, + colorpicker_get_color (GNOME_COLOR_PICKER (source_dialog->source_color))); } static gboolean @@ -512,6 +551,13 @@ source_group_changed_sensitive (SourceDialog *source_dialog) general_update_dialog (source_dialog); } +static void +new_calendar_test_uri (SourceDialog *source_dialog) +{ + gnome_url_show (gtk_entry_get_text (GTK_ENTRY (source_dialog->uri_entry)), + NULL) +} + static void new_calendar_cancel (SourceDialog *source_dialog) { @@ -584,13 +630,19 @@ calendar_setup_new_calendar (GtkWindow *parent) source_dialog->add_button = glade_xml_get_widget (source_dialog->gui_xml, "add-button"); gtk_widget_set_sensitive (source_dialog->add_button, FALSE); - g_signal_connect_swapped (source_dialog->add_button, "clicked", G_CALLBACK (new_calendar_add), source_dialog); + + source_dialog->source_color = glade_xml_get_widget (source_dialog->gui_xml, "source-color"); + g_object_weak_ref (G_OBJECT (source_dialog->window), (GWeakNotify) source_dialog_destroy, source_dialog); source_to_dialog (source_dialog); + + g_signal_connect_swapped (glade_xml_get_widget (source_dialog->gui_xml, "uri-button"), "clicked", + G_CALLBACK (new_calendar_test_uri), source_dialog); + gtk_window_set_type_hint (GTK_WINDOW (source_dialog->window), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_modal (GTK_WINDOW (source_dialog->window), TRUE); diff --git a/calendar/gui/dialogs/calendar-setup.glade b/calendar/gui/dialogs/calendar-setup.glade index 0c5b0e1b05..bd67f362eb 100644 --- a/calendar/gui/dialogs/calendar-setup.glade +++ b/calendar/gui/dialogs/calendar-setup.glade @@ -36,7 +36,7 @@ True True 0 - Chillonia + True * True @@ -209,6 +209,7 @@ 0.5 0 0 + source-color 0 @@ -220,24 +221,6 @@ - - - True - True - True - False - Pick a color - - - 1 - 2 - 2 - 3 - fill - - - - True @@ -331,6 +314,7 @@ 0.5 0 0 + group-optionmenu 0 @@ -355,6 +339,7 @@ 0.5 0 0 + name-entry 0 @@ -365,6 +350,24 @@ + + + + True + True + True + False + Pick a color + + + 1 + 2 + 2 + 3 + fill + + + 0 @@ -1290,6 +1293,7 @@ 0.5 0 0 + group-color 0 -- cgit