diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-19 01:25:26 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-19 01:25:26 +0000 |
commit | bd73a312f06ad6d1a448cab873f309264ee24b46 (patch) | |
tree | 62afa03ae970e3260e0677d02a2391e1d0350a1d /examples/calendar | |
parent | c3940d4a07a6855998e1d991afeb92f3253bef56 (diff) | |
download | gtk+-bd73a312f06ad6d1a448cab873f309264ee24b46.tar.gz |
Trivial formatting fixes to all examples, simple functional fixes to
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
fixes to all examples, simple functional fixes to rangewidgets example.
Diffstat (limited to 'examples/calendar')
-rw-r--r-- | examples/calendar/calendar.c | 131 |
1 files changed, 67 insertions, 64 deletions
diff --git a/examples/calendar/calendar.c b/examples/calendar/calendar.c index 5e395b9150..ce1cb81998 100644 --- a/examples/calendar/calendar.c +++ b/examples/calendar/calendar.c @@ -59,11 +59,11 @@ void calendar_date_to_string( CalendarData *data, time_t time; memset (&tm, 0, sizeof (tm)); - gtk_calendar_get_date (GTK_CALENDAR(data->window), + gtk_calendar_get_date (GTK_CALENDAR (data->window), &tm.tm_year, &tm.tm_mon, &tm.tm_mday); tm.tm_year -= TM_YEAR_BASE; - time = mktime(&tm); - strftime (buffer, buff_len-1, "%x", gmtime(&time)); + time = mktime (&tm); + strftime (buffer, buff_len-1, "%x", gmtime (&time)); } void calendar_set_signal_strings( char *sig_str, @@ -107,15 +107,18 @@ void calendar_day_selected_double_click( GtkWidget *widget, calendar_set_signal_strings (buffer, data); memset (&tm, 0, sizeof (tm)); - gtk_calendar_get_date (GTK_CALENDAR(data->window), + gtk_calendar_get_date (GTK_CALENDAR (data->window), &tm.tm_year, &tm.tm_mon, &tm.tm_mday); tm.tm_year -= TM_YEAR_BASE; - if(GTK_CALENDAR(data->window)->marked_date[tm.tm_mday-1] == 0) { - gtk_calendar_mark_day(GTK_CALENDAR(data->window),tm.tm_mday); - } else { - gtk_calendar_unmark_day(GTK_CALENDAR(data->window),tm.tm_mday); - } + if (GTK_CALENDAR (data->window)->marked_date[tm.tm_mday-1] == 0) + { + gtk_calendar_mark_day (GTK_CALENDAR (data->window), tm.tm_mday); + } + else + { + gtk_calendar_unmark_day (GTK_CALENDAR (data->window), tm.tm_mday); + } } void calendar_prev_month( GtkWidget *widget, @@ -158,8 +161,8 @@ void calendar_next_year( GtkWidget *widget, void calendar_set_flags( CalendarData *calendar ) { gint i; - gint options=0; - for (i=0;i<5;i++) + gint options = 0; + for (i = 0; i < 5; i++) if (calendar->settings[i]) { options=options + (1<<i); @@ -173,13 +176,13 @@ void calendar_toggle_flag( GtkWidget *toggle, { gint i; gint j; - j=0; - for (i=0; i<5; i++) + j = 0; + for (i = 0; i < 5; i++) if (calendar->flag_checkboxes[i] == toggle) j = i; - calendar->settings[j]=!calendar->settings[j]; - calendar_set_flags(calendar); + calendar->settings[j] = !calendar->settings[j]; + calendar_set_flags (calendar); } @@ -189,7 +192,7 @@ void calendar_font_selection_ok( GtkWidget *button, GtkStyle *style; PangoFontDescription *font_desc; - calendar->font = gtk_font_selection_dialog_get_font_name( + calendar->font = gtk_font_selection_dialog_get_font_name ( GTK_FONT_SELECTION_DIALOG (calendar->font_dialog)); if (calendar->window) { @@ -210,7 +213,7 @@ void calendar_select_font( GtkWidget *button, if (!calendar->font_dialog) { window = gtk_font_selection_dialog_new ("Font Selection Dialog"); - g_return_if_fail(GTK_IS_FONT_SELECTION_DIALOG(window)); + g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (window)); calendar->font_dialog = window; gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); @@ -220,7 +223,7 @@ void calendar_select_font( GtkWidget *button, &calendar->font_dialog); g_signal_connect (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->ok_button), - "clicked", GTK_SIGNAL_FUNC(calendar_font_selection_ok), + "clicked", GTK_SIGNAL_FUNC (calendar_font_selection_ok), calendar); g_signal_connect_swapped (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->cancel_button), "clicked", @@ -267,44 +270,44 @@ void create_calendar() calendar_data.font = NULL; calendar_data.font_dialog = NULL; - for (i=0; i<5; i++) { - calendar_data.settings[i]=0; + for (i = 0; i < 5; i++) { + calendar_data.settings[i] = 0; } window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(window), "GtkCalendar Example"); + gtk_window_set_title (GTK_WINDOW (window), "GtkCalendar Example"); gtk_container_set_border_width (GTK_CONTAINER (window), 5); - g_signal_connect(GTK_OBJECT(window), "destroy", - GTK_SIGNAL_FUNC(gtk_main_quit), - NULL); - g_signal_connect(GTK_OBJECT(window), "delete-event", - GTK_SIGNAL_FUNC(gtk_false), - NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_main_quit), + NULL); + g_signal_connect (GTK_OBJECT (window), "delete-event", + GTK_SIGNAL_FUNC (gtk_false), + NULL); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); - vbox = gtk_vbox_new(FALSE, DEF_PAD); + vbox = gtk_vbox_new (FALSE, DEF_PAD); gtk_container_add (GTK_CONTAINER (window), vbox); /* * The top part of the window, Calendar, flags and fontsel. */ - hbox = gtk_hbox_new(FALSE, DEF_PAD); - gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, DEF_PAD); - hbbox = gtk_hbutton_box_new(); - gtk_box_pack_start(GTK_BOX(hbox), hbbox, FALSE, FALSE, DEF_PAD); - gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_SPREAD); + hbox = gtk_hbox_new (FALSE, DEF_PAD); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, DEF_PAD); + hbbox = gtk_hbutton_box_new (); + gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, DEF_PAD); + gtk_button_box_set_layout (GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_SPREAD); gtk_box_set_spacing (GTK_BOX (hbbox), 5); /* Calendar widget */ - frame = gtk_frame_new("Calendar"); - gtk_box_pack_start(GTK_BOX(hbbox), frame, FALSE, TRUE, DEF_PAD); - calendar=gtk_calendar_new(); + frame = gtk_frame_new ("Calendar"); + gtk_box_pack_start (GTK_BOX (hbbox), frame, FALSE, TRUE, DEF_PAD); + calendar=gtk_calendar_new (); calendar_data.window = calendar; - calendar_set_flags(&calendar_data); - gtk_calendar_mark_day ( GTK_CALENDAR(calendar), 19); - gtk_container_add( GTK_CONTAINER( frame), calendar); + calendar_set_flags (&calendar_data); + gtk_calendar_mark_day (GTK_CALENDAR (calendar), 19); + gtk_container_add( GTK_CONTAINER (frame), calendar); g_signal_connect (GTK_OBJECT (calendar), "month_changed", GTK_SIGNAL_FUNC (calendar_month_changed), &calendar_data); @@ -331,43 +334,43 @@ void create_calendar() separator = gtk_vseparator_new (); gtk_box_pack_start (GTK_BOX (hbox), separator, FALSE, TRUE, 0); - vbox2 = gtk_vbox_new(FALSE, DEF_PAD); - gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, DEF_PAD); + vbox2 = gtk_vbox_new (FALSE, DEF_PAD); + gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, DEF_PAD); /* Build the Right frame with the flags in */ - frame = gtk_frame_new("Flags"); - gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, DEF_PAD); - vbox3 = gtk_vbox_new(TRUE, DEF_PAD_SMALL); - gtk_container_add(GTK_CONTAINER(frame), vbox3); + frame = gtk_frame_new ("Flags"); + gtk_box_pack_start (GTK_BOX (vbox2), frame, TRUE, TRUE, DEF_PAD); + vbox3 = gtk_vbox_new (TRUE, DEF_PAD_SMALL); + gtk_container_add (GTK_CONTAINER (frame), vbox3); for (i = 0; i < 5; i++) { - toggle = gtk_check_button_new_with_label(flags[i].label); + toggle = gtk_check_button_new_with_label (flags[i].label); g_signal_connect (GTK_OBJECT (toggle), - "toggled", - GTK_SIGNAL_FUNC(calendar_toggle_flag), - &calendar_data); + "toggled", + GTK_SIGNAL_FUNC (calendar_toggle_flag), + &calendar_data); gtk_box_pack_start (GTK_BOX (vbox3), toggle, TRUE, TRUE, 0); - calendar_data.flag_checkboxes[i]=toggle; + calendar_data.flag_checkboxes[i] = toggle; } /* Build the right font-button */ - button = gtk_button_new_with_label("Font..."); + button = gtk_button_new_with_label ("Font..."); g_signal_connect (GTK_OBJECT (button), - "clicked", - GTK_SIGNAL_FUNC(calendar_select_font), - &calendar_data); + "clicked", + GTK_SIGNAL_FUNC (calendar_select_font), + &calendar_data); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); /* * Build the Signal-event part. */ - frame = gtk_frame_new("Signal events"); - gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, DEF_PAD); + frame = gtk_frame_new ("Signal events"); + gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, DEF_PAD); - vbox2 = gtk_vbox_new(TRUE, DEF_PAD_SMALL); - gtk_container_add(GTK_CONTAINER(frame), vbox2); + vbox2 = gtk_vbox_new (TRUE, DEF_PAD_SMALL); + gtk_container_add (GTK_CONTAINER (frame), vbox2); hbox = gtk_hbox_new (FALSE, 3); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, TRUE, 0); @@ -392,17 +395,17 @@ void create_calendar() bbox = gtk_hbutton_box_new (); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); - gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); + gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END); button = gtk_button_new_with_label ("Close"); g_signal_connect (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (gtk_main_quit), - NULL); + GTK_SIGNAL_FUNC (gtk_main_quit), + NULL); gtk_container_add (GTK_CONTAINER (bbox), button); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_widget_grab_default (button); - gtk_widget_show_all(window); + gtk_widget_show_all (window); } @@ -411,9 +414,9 @@ int main(int argc, { gtk_init (&argc, &argv); - create_calendar(); + create_calendar (); - gtk_main(); + gtk_main (); return 0; } |