/* Display a window containing the standard calendar widget. */ static GtkWidget * dclock_create_calendar(DClockPlugin * dc) { /* Create a new window. */ GtkWidget * win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(win), 180, 180); gtk_window_set_decorated(GTK_WINDOW(win), FALSE); gtk_window_set_resizable(GTK_WINDOW(win), FALSE); gtk_container_set_border_width(GTK_CONTAINER(win), 5); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(win), TRUE); gtk_window_set_skip_pager_hint(GTK_WINDOW(win), TRUE); gtk_window_stick(GTK_WINDOW(win)); /* Create a vertical box as a child of the window. */ GtkWidget * box = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(box)); /* Create a standard calendar widget as a child of the vertical box. */ GtkWidget * calendar = gtk_calendar_new(); gtk_calendar_display_options( GTK_CALENDAR(calendar), GTK_CALENDAR_SHOW_WEEK_NUMBERS | GTK_CALENDAR_SHOW_DAY_NAMES | GTK_CALENDAR_SHOW_HEADING); gtk_box_pack_start_defaults(GTK_BOX(box), calendar); /* Connect signals. */ g_signal_connect(G_OBJECT(win), "map", G_CALLBACK(dclock_popup_map), dc); /* Return the widget. */ return win; }
static GtkWidget * calendar_new (GladeXML *xml, GladeWidgetInfo *info) { GtkWidget *wid = gtk_calendar_new(); GList *tmp; GtkCalendarDisplayOptions dopt = 0; for (tmp = info->attributes; tmp; tmp = tmp->next) { GladeAttribute *attr = tmp->data; if (!strcmp(attr->name, "show_heading")) { if (attr->value[0] == 'T') dopt |= GTK_CALENDAR_SHOW_HEADING; } else if (!strcmp(attr->name, "show_day_names")) { if (attr->value[0] == 'T') dopt |= GTK_CALENDAR_SHOW_DAY_NAMES; } else if (!strcmp(attr->name, "no_month_change")) { if (attr->value[0] == 'T') dopt |= GTK_CALENDAR_NO_MONTH_CHANGE; } else if (!strcmp(attr->name, "show_week_numbers")) { if (attr->value[0] == 'T') dopt |= GTK_CALENDAR_SHOW_WEEK_NUMBERS; } else if (!strcmp(attr->name, "week_start_monday")) { if (attr->value[0] == 'T') dopt |= GTK_CALENDAR_WEEK_START_MONDAY; } } gtk_calendar_display_options(GTK_CALENDAR(wid), dopt); return wid; }
int main(int argc, char** argv) { GtkWidget *window; GtkWidget *box; GtkWidget *button; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); box = gtk_vbox_new(FALSE, 10); gtk_container_add(GTK_CONTAINER(window), box); calendar = gtk_calendar_new(); gtk_calendar_display_options(GTK_CALENDAR(calendar), GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES| GTK_CALENDAR_SHOW_WEEK_NUMBERS|GTK_CALENDAR_WEEK_START_MONDAY); gtk_calendar_select_month(GTK_CALENDAR(calendar),8,1985); gtk_calendar_select_day(GTK_CALENDAR(calendar),8); gtk_box_pack_start(GTK_BOX(box), calendar, TRUE, TRUE, 5); button = gtk_button_new_with_label("OK"); gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 5); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_event), NULL); gtk_widget_show_all(window); gtk_main(); }
void popcalendar_run(GtkWidget *parent, guint date[], int markfirstyear, guint32 marks[]) { GtkWidget *win; GtkWidget *frame, *box; GtkWidget *cal; calendar_data cdata_actual = {0}, *cdata = &cdata_actual; win = gtk_window_new(GTK_WINDOW_POPUP); cdata->win = win; cdata->date = date; cdata->marks = marks; cdata->markfirstyear = markfirstyear; gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(parent)); gtk_window_set_modal(GTK_WINDOW(win), TRUE); gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_MOUSE); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(gtk_main_quit), NULL); frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); box = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(box), 5); /*hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("Select day:"), FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox), gtk_button_new_with_label("x"), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);*/ cal = gtk_calendar_new(); if (date[0] != 0) { gtk_calendar_select_month(GTK_CALENDAR(cal), date[1]-1, date[0]); gtk_calendar_select_day(GTK_CALENDAR(cal), date[2]); } else { gtk_calendar_get_date(GTK_CALENDAR(cal), &date[0], &date[1], &date[2]); } g_signal_connect(G_OBJECT(cal), "day-selected", G_CALLBACK(day_selected), cdata); g_signal_connect(G_OBJECT(cal), "month-changed", G_CALLBACK(month_changed), cdata); gtk_calendar_display_options(GTK_CALENDAR(cal), GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES); popcalendar_set_marks(GTK_CALENDAR(cal), marks[(date[0]-markfirstyear)*12 + date[1]-1]); gtk_box_pack_start(GTK_BOX(box), cal, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(frame), box); gtk_container_add(GTK_CONTAINER(win), frame); gtk_widget_show_all(frame); gtk_widget_show(win); gtk_main(); }
static GtkWidget * pop_calendar_window(GtkWidget *parent, int orientation, gboolean week_start_monday, const char *date_string) { GtkWidget *window; GtkWidget *frame; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *cal; GtkWidget *entry; GtkWidget *label; GtkCalendarDisplayOptions display_options; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE); gtk_window_set_skip_pager_hint(GTK_WINDOW(window), TRUE); g_object_set_data(G_OBJECT(window), "calendar-parent", parent); frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER(window), frame); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add (GTK_CONTAINER(frame), vbox); cal = gtk_calendar_new(); display_options = GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_WEEK_NUMBERS | GTK_CALENDAR_SHOW_DAY_NAMES; if (week_start_monday) display_options |= GTK_CALENDAR_WEEK_START_MONDAY; gtk_calendar_display_options(GTK_CALENDAR (cal), display_options); gtk_box_pack_start(GTK_BOX(vbox), cal, TRUE, TRUE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); label = gtk_label_new(_("Date:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry), date_string); gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(on_calendar_entry_activated), cal); g_signal_connect_after(G_OBJECT(window), "realize", G_CALLBACK(on_calendar_realized), GINT_TO_POINTER(orientation)); gtk_widget_show_all(window); return window; }
void calendar_set_flags( CalendarData *calendar ) { gint i; gint options=0; for (i=0;i<5;i++) if (calendar->settings[i]) { options=options + (1<<i); } if (calendar->window) gtk_calendar_display_options (GTK_CALENDAR (calendar->window), options); }
int clip_GTK_CALENDARDISPLAYOPTIONS(ClipMachine * ClipMachineMemory) { C_widget *ccal = _fetch_cw_arg(ClipMachineMemory); GtkCalendarDisplayOptions flags = _clip_parni(ClipMachineMemory, 2); CHECKCWID(ccal, GTK_IS_CALENDAR); CHECKARG(2, NUMERIC_type_of_ClipVarType); gtk_calendar_display_options(GTK_CALENDAR(ccal->widget), flags); return 0; err: return 1; }
static VALUE rg_display_options(int argc, VALUE *argv, VALUE self) { VALUE flags; rb_scan_args(argc, argv, "01", &flags); if (NIL_P(flags)){ return GFLAGS2RVAL(gtk_calendar_get_display_options(_SELF(self)), GTK_TYPE_CALENDAR_DISPLAY_OPTIONS); } else { /* This is for backward compatibility. */ rb_warning("Gtk::Calendar#display_options(flags) has been deprecated. Use Gtk::Calendar#set_display_options(flags)."); gtk_calendar_display_options(_SELF(self), RVAL2GFLAGS(flags, GTK_TYPE_CALENDAR_DISPLAY_OPTIONS)); } return self; }
int main(int argc, char** argv) { GtkWidget *window; GtkWidget *calendar; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); calendar = gtk_calendar_new(); gtk_calendar_display_options(GTK_CALENDAR(calendar), GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES| GTK_CALENDAR_SHOW_WEEK_NUMBERS|GTK_CALENDAR_WEEK_START_MONDAY); gtk_calendar_select_month(GTK_CALENDAR(calendar),8,1985); gtk_calendar_select_day(GTK_CALENDAR(calendar),8); gtk_container_add(GTK_CONTAINER(window), calendar); gtk_widget_show_all(window); gtk_main(); }
GtkWidget* create_MainWindow (void) { GtkWidget *MainWindow; GtkWidget *dialog_vbox1; GtkWidget *notebook1; GtkWidget *vbox1; GtkWidget *hbox1; GtkWidget *frame1; GtkWidget *calendar1; GtkWidget *label3; GtkWidget *frame2; GtkWidget *table1; GtkWidget *label6; GtkWidget *label7; GtkWidget *label8; GtkWidget *label9; GtkWidget *label10; GtkObject *spinbutton1_adj; GtkWidget *spinbutton1; GtkObject *spinbutton2_adj; GtkWidget *spinbutton2; GtkObject *spinbutton3_adj; GtkWidget *spinbutton3; GtkWidget *label4; GtkWidget *frame3; GtkWidget *vbox2; GtkWidget *label11; GtkWidget *checkbutton1; GtkWidget *hbox2; GtkWidget *label12; GtkWidget *combo1; GtkWidget *combo_entry1; GtkWidget *label5; GtkWidget *label1; GtkWidget *vbox3; GtkWidget *label13; GtkWidget *drawingarea1; GtkWidget *label14; GtkWidget *hseparator1; GtkWidget *scrolledwindow1; GtkWidget *treeview1; GtkWidget *checkbutton2; GtkWidget *label2; GtkWidget *dialog_action_area1; GtkWidget *helpbutton1; GtkWidget *cancelbutton1; GtkWidget *okbutton1; MainWindow = gtk_dialog_new (); gtk_widget_set_size_request (MainWindow, 500, 650); gtk_window_set_title (GTK_WINDOW (MainWindow), _("Date / Time Properties")); gtk_window_set_position (GTK_WINDOW (MainWindow), GTK_WIN_POS_CENTER); dialog_vbox1 = GTK_DIALOG (MainWindow)->vbox; gtk_widget_show (dialog_vbox1); notebook1 = gtk_notebook_new (); gtk_widget_show (notebook1); gtk_box_pack_start (GTK_BOX (dialog_vbox1), notebook1, TRUE, TRUE, 0); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (notebook1), vbox1); hbox1 = gtk_hbox_new (TRUE, 0); gtk_widget_show (hbox1); gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0); frame1 = gtk_frame_new (NULL); gtk_widget_show (frame1); gtk_box_pack_start (GTK_BOX (hbox1), frame1, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (frame1), 8); calendar1 = gtk_calendar_new (); gtk_widget_show (calendar1); gtk_container_add (GTK_CONTAINER (frame1), calendar1); gtk_calendar_display_options (GTK_CALENDAR (calendar1), GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES); label3 = gtk_label_new (_("Date")); gtk_widget_show (label3); gtk_frame_set_label_widget (GTK_FRAME (frame1), label3); gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT); frame2 = gtk_frame_new (NULL); gtk_widget_show (frame2); gtk_box_pack_start (GTK_BOX (hbox1), frame2, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (frame2), 8); table1 = gtk_table_new (4, 2, TRUE); gtk_widget_show (table1); gtk_container_add (GTK_CONTAINER (frame2), table1); label6 = gtk_label_new (_("Current Time:")); gtk_widget_show (label6); gtk_table_attach (GTK_TABLE (table1), label6, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label6), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5); label7 = gtk_label_new (_("00:00:00")); gtk_widget_show (label7); gtk_table_attach (GTK_TABLE (table1), label7, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label7), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (label7), 0, 0.5); label8 = gtk_label_new (_("Hour:")); gtk_widget_show (label8); gtk_table_attach (GTK_TABLE (table1), label8, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label8), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5); label9 = gtk_label_new (_("Minute:")); gtk_widget_show (label9); gtk_table_attach (GTK_TABLE (table1), label9, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label9), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (label9), 0, 0.5); label10 = gtk_label_new (_("Second:")); gtk_widget_show (label10); gtk_table_attach (GTK_TABLE (table1), label10, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_label_set_justify (GTK_LABEL (label10), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (label10), 0, 0.5); spinbutton1_adj = gtk_adjustment_new (22, 0, 23, 1, 10, 10); spinbutton1 = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton1_adj), 1, 0); gtk_widget_show (spinbutton1); gtk_table_attach (GTK_TABLE (table1), spinbutton1, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton1), TRUE); gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (spinbutton1), TRUE); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinbutton1), TRUE); spinbutton2_adj = gtk_adjustment_new (0, 0, 59, 1, 10, 10); spinbutton2 = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton2_adj), 1, 0); gtk_widget_show (spinbutton2); gtk_table_attach (GTK_TABLE (table1), spinbutton2, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton2), TRUE); gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (spinbutton2), TRUE); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinbutton2), TRUE); spinbutton3_adj = gtk_adjustment_new (0, 0, 59, 1, 10, 10); spinbutton3 = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton3_adj), 1, 0); gtk_widget_show (spinbutton3); gtk_table_attach (GTK_TABLE (table1), spinbutton3, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton3), TRUE); gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (spinbutton3), TRUE); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinbutton3), TRUE); label4 = gtk_label_new (_("Time")); gtk_widget_show (label4); gtk_frame_set_label_widget (GTK_FRAME (frame2), label4); gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_LEFT); frame3 = gtk_frame_new (NULL); gtk_widget_show (frame3); gtk_box_pack_start (GTK_BOX (vbox1), frame3, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (frame3), 8); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox2); gtk_container_add (GTK_CONTAINER (frame3), vbox2); label11 = gtk_label_new (_("Your computer can synchronize its clock with a remote time server using the Network Time Protocol")); gtk_widget_show (label11); gtk_box_pack_start (GTK_BOX (vbox2), label11, FALSE, FALSE, 0); gtk_label_set_justify (GTK_LABEL (label11), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label11), TRUE); checkbutton1 = gtk_check_button_new_with_mnemonic (_("_Enable Network Time Protocol")); gtk_widget_show (checkbutton1); gtk_box_pack_start (GTK_BOX (vbox2), checkbutton1, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (checkbutton1), 8); hbox2 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox2); gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox2), 8); label12 = gtk_label_new (_("Server: ")); gtk_widget_show (label12); gtk_box_pack_start (GTK_BOX (hbox2), label12, FALSE, FALSE, 0); gtk_label_set_justify (GTK_LABEL (label12), GTK_JUSTIFY_LEFT); combo1 = gtk_combo_new (); g_object_set_data (G_OBJECT (GTK_COMBO (combo1)->popwin), "GladeParentKey", combo1); gtk_widget_show (combo1); gtk_box_pack_start (GTK_BOX (hbox2), combo1, TRUE, TRUE, 0); combo_entry1 = GTK_COMBO (combo1)->entry; gtk_widget_show (combo_entry1); label5 = gtk_label_new (_("Network Time Protocol")); gtk_widget_show (label5); gtk_frame_set_label_widget (GTK_FRAME (frame3), label5); gtk_label_set_justify (GTK_LABEL (label5), GTK_JUSTIFY_LEFT); label1 = gtk_label_new (_("Date & Time")); gtk_widget_show (label1); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label1); gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT); vbox3 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox3); gtk_container_add (GTK_CONTAINER (notebook1), vbox3); label13 = gtk_label_new (_("Please select the nearest city in your timezone:")); gtk_widget_show (label13); gtk_box_pack_start (GTK_BOX (vbox3), label13, FALSE, FALSE, 0); gtk_label_set_justify (GTK_LABEL (label13), GTK_JUSTIFY_LEFT); drawingarea1 = gtk_drawing_area_new (); gtk_widget_show (drawingarea1); gtk_box_pack_start (GTK_BOX (vbox3), drawingarea1, FALSE, TRUE, 0); gtk_widget_set_size_request (drawingarea1, 480, 240); label14 = gtk_label_new (""); gtk_widget_show (label14); gtk_box_pack_start (GTK_BOX (vbox3), label14, FALSE, FALSE, 0); gtk_label_set_justify (GTK_LABEL (label14), GTK_JUSTIFY_LEFT); hseparator1 = gtk_hseparator_new (); gtk_widget_show (hseparator1); gtk_box_pack_start (GTK_BOX (vbox3), hseparator1, FALSE, FALSE, 8); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow1); gtk_box_pack_start (GTK_BOX (vbox3), scrolledwindow1, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow1), 8); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); treeview1 = gtk_tree_view_new (); gtk_widget_show (treeview1); gtk_container_add (GTK_CONTAINER (scrolledwindow1), treeview1); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview1), FALSE); checkbutton2 = gtk_check_button_new_with_mnemonic (_("_System clock uses UTC")); gtk_widget_show (checkbutton2); gtk_box_pack_start (GTK_BOX (vbox3), checkbutton2, FALSE, FALSE, 0); label2 = gtk_label_new (_("Timezone")); gtk_widget_show (label2); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 1), label2); gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT); dialog_action_area1 = GTK_DIALOG (MainWindow)->action_area; gtk_widget_show (dialog_action_area1); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); helpbutton1 = gtk_button_new_from_stock ("gtk-help"); gtk_widget_show (helpbutton1); gtk_dialog_add_action_widget (GTK_DIALOG (MainWindow), helpbutton1, GTK_RESPONSE_HELP); GTK_WIDGET_SET_FLAGS (helpbutton1, GTK_CAN_DEFAULT); cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (cancelbutton1); gtk_dialog_add_action_widget (GTK_DIALOG (MainWindow), cancelbutton1, GTK_RESPONSE_CANCEL); GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); okbutton1 = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (okbutton1); gtk_dialog_add_action_widget (GTK_DIALOG (MainWindow), okbutton1, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); g_signal_connect ((gpointer) MainWindow, "delete_event", G_CALLBACK (on_MainWindow_close), NULL); g_signal_connect ((gpointer) calendar1, "day_selected", G_CALLBACK (on_calendar1_day_selected), NULL); g_signal_connect ((gpointer) calendar1, "month_changed", G_CALLBACK (on_calendar1_month_changed), NULL); g_signal_connect ((gpointer) spinbutton1, "changed", G_CALLBACK (on_spinbutton1_changed), NULL); g_signal_connect ((gpointer) spinbutton2, "changed", G_CALLBACK (on_spinbutton2_changed), NULL); g_signal_connect ((gpointer) spinbutton3, "changed", G_CALLBACK (on_spinbutton3_changed), NULL); g_signal_connect ((gpointer) checkbutton1, "toggled", G_CALLBACK (on_checkbutton1_toggled), NULL); g_signal_connect ((gpointer) combo_entry1, "changed", G_CALLBACK (on_combo_entry1_changed), NULL); g_signal_connect ((gpointer) drawingarea1, "motion_notify_event", G_CALLBACK (on_drawingarea1_motion_notify_event), NULL); g_signal_connect ((gpointer) drawingarea1, "button_press_event", G_CALLBACK (on_drawingarea1_button_press_event), NULL); g_signal_connect ((gpointer) drawingarea1, "leave_notify_event", G_CALLBACK (on_drawingarea1_leave_notify_event), NULL); g_signal_connect ((gpointer) drawingarea1, "expose_event", G_CALLBACK (on_drawingarea1_expose_event), NULL); g_signal_connect ((gpointer) treeview1, "row_activated", G_CALLBACK (on_treeview1_row_activated), NULL); g_signal_connect ((gpointer) checkbutton2, "toggled", G_CALLBACK (on_checkbutton2_toggled), NULL); g_signal_connect ((gpointer) helpbutton1, "clicked", G_CALLBACK (on_helpbutton1_clicked), NULL); g_signal_connect ((gpointer) cancelbutton1, "clicked", G_CALLBACK (on_cancelbutton1_clicked), NULL); g_signal_connect ((gpointer) okbutton1, "clicked", G_CALLBACK (on_okbutton1_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (MainWindow, MainWindow, "MainWindow"); GLADE_HOOKUP_OBJECT_NO_REF (MainWindow, dialog_vbox1, "dialog_vbox1"); GLADE_HOOKUP_OBJECT (MainWindow, notebook1, "notebook1"); GLADE_HOOKUP_OBJECT (MainWindow, vbox1, "vbox1"); GLADE_HOOKUP_OBJECT (MainWindow, hbox1, "hbox1"); GLADE_HOOKUP_OBJECT (MainWindow, frame1, "frame1"); GLADE_HOOKUP_OBJECT (MainWindow, calendar1, "calendar1"); GLADE_HOOKUP_OBJECT (MainWindow, label3, "label3"); GLADE_HOOKUP_OBJECT (MainWindow, frame2, "frame2"); GLADE_HOOKUP_OBJECT (MainWindow, table1, "table1"); GLADE_HOOKUP_OBJECT (MainWindow, label6, "label6"); GLADE_HOOKUP_OBJECT (MainWindow, label7, "label7"); GLADE_HOOKUP_OBJECT (MainWindow, label8, "label8"); GLADE_HOOKUP_OBJECT (MainWindow, label9, "label9"); GLADE_HOOKUP_OBJECT (MainWindow, label10, "label10"); GLADE_HOOKUP_OBJECT (MainWindow, spinbutton1, "spinbutton1"); GLADE_HOOKUP_OBJECT (MainWindow, spinbutton2, "spinbutton2"); GLADE_HOOKUP_OBJECT (MainWindow, spinbutton3, "spinbutton3"); GLADE_HOOKUP_OBJECT (MainWindow, label4, "label4"); GLADE_HOOKUP_OBJECT (MainWindow, frame3, "frame3"); GLADE_HOOKUP_OBJECT (MainWindow, vbox2, "vbox2"); GLADE_HOOKUP_OBJECT (MainWindow, label11, "label11"); GLADE_HOOKUP_OBJECT (MainWindow, checkbutton1, "checkbutton1"); GLADE_HOOKUP_OBJECT (MainWindow, hbox2, "hbox2"); GLADE_HOOKUP_OBJECT (MainWindow, label12, "label12"); GLADE_HOOKUP_OBJECT (MainWindow, combo1, "combo1"); GLADE_HOOKUP_OBJECT (MainWindow, combo_entry1, "combo_entry1"); GLADE_HOOKUP_OBJECT (MainWindow, label5, "label5"); GLADE_HOOKUP_OBJECT (MainWindow, label1, "label1"); GLADE_HOOKUP_OBJECT (MainWindow, vbox3, "vbox3"); GLADE_HOOKUP_OBJECT (MainWindow, label13, "label13"); GLADE_HOOKUP_OBJECT (MainWindow, drawingarea1, "drawingarea1"); GLADE_HOOKUP_OBJECT (MainWindow, label14, "label14"); GLADE_HOOKUP_OBJECT (MainWindow, hseparator1, "hseparator1"); GLADE_HOOKUP_OBJECT (MainWindow, scrolledwindow1, "scrolledwindow1"); GLADE_HOOKUP_OBJECT (MainWindow, treeview1, "treeview1"); GLADE_HOOKUP_OBJECT (MainWindow, checkbutton2, "checkbutton2"); GLADE_HOOKUP_OBJECT (MainWindow, label2, "label2"); GLADE_HOOKUP_OBJECT_NO_REF (MainWindow, dialog_action_area1, "dialog_action_area1"); GLADE_HOOKUP_OBJECT (MainWindow, helpbutton1, "helpbutton1"); GLADE_HOOKUP_OBJECT (MainWindow, cancelbutton1, "cancelbutton1"); GLADE_HOOKUP_OBJECT (MainWindow, okbutton1, "okbutton1"); return MainWindow; }
GtkWidget * range_widget_create() { GtkWidget *range_dialog; GtkWidget *dialog_vbox4; GtkWidget *vbox7; GtkWidget *hbox46; GtkWidget *label43; GtkWidget *label44; GtkWidget *hbox42; GtkWidget *hbox43; GtkWidget *hbox44; GtkObject *start_hours_adj; GtkObject *start_minutes_adj; GtkObject *start_seconds_adj; GtkWidget *hbox45; GtkObject *end_hours_adj; GtkObject *end_minutes_adj; GtkObject *end_seconds_adj; GtkWidget *dialog_action_area4; GtkWidget *cancel_button; GtkWidget *ok_button; GtkWidget *alignment55; GtkWidget *hbox341; GtkWidget *image49; GtkWidget *label97; gchar *val; range_dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(range_dialog), TIMELOG_TITLE); gtk_window_set_modal(GTK_WINDOW(range_dialog), FALSE); gtk_window_set_type_hint(GTK_WINDOW(range_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); dialog_vbox4 = GTK_DIALOG(range_dialog)->vbox; gtk_widget_show(dialog_vbox4); vbox7 = gtk_vbox_new(FALSE, 0); gtk_widget_show(vbox7); gtk_box_pack_start(GTK_BOX(dialog_vbox4), vbox7, TRUE, TRUE, 0); hbox46 = gtk_hbox_new(FALSE, 20); gtk_widget_show(hbox46); gtk_box_pack_start(GTK_BOX(vbox7), hbox46, FALSE, FALSE, 5); label43 = gtk_label_new(_("Start Time")); gtk_widget_show(label43); gtk_box_pack_start(GTK_BOX(hbox46), label43, TRUE, TRUE, 0); label44 = gtk_label_new(_("End Time")); gtk_widget_show(label44); gtk_box_pack_start(GTK_BOX(hbox46), label44, TRUE, TRUE, 0); hbox42 = gtk_hbox_new(FALSE, 20); gtk_widget_show(hbox42); gtk_box_pack_start(GTK_BOX(vbox7), hbox42, TRUE, TRUE, 0); start_calendar = gtk_calendar_new(); gtk_widget_show(start_calendar); gtk_box_pack_start(GTK_BOX(hbox42), start_calendar, TRUE, TRUE, 0); gtk_calendar_display_options(GTK_CALENDAR(start_calendar), GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES); end_calendar = gtk_calendar_new(); gtk_widget_show(end_calendar); gtk_box_pack_start(GTK_BOX(hbox42), end_calendar, TRUE, TRUE, 0); gtk_calendar_display_options(GTK_CALENDAR(end_calendar), GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES); hbox43 = gtk_hbox_new(FALSE, 20); gtk_widget_show(hbox43); gtk_box_pack_start(GTK_BOX(vbox7), hbox43, FALSE, TRUE, 10); hbox44 = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox44); gtk_box_pack_start(GTK_BOX(hbox43), hbox44, TRUE, TRUE, 0); start_hours_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10); start_hours = gtk_spin_button_new(GTK_ADJUSTMENT(start_hours_adj), 1, 0); gtk_widget_show(start_hours); gtk_box_pack_start(GTK_BOX(hbox44), start_hours, TRUE, TRUE, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(start_hours), TRUE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(start_hours), TRUE); start_minutes_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10); start_minutes = gtk_spin_button_new(GTK_ADJUSTMENT(start_minutes_adj), 1, 0); gtk_widget_show(start_minutes); gtk_box_pack_start(GTK_BOX(hbox44), start_minutes, TRUE, TRUE, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(start_minutes), TRUE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(start_minutes), TRUE); start_seconds_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10); start_seconds = gtk_spin_button_new(GTK_ADJUSTMENT(start_seconds_adj), 1, 0); gtk_widget_show(start_seconds); gtk_box_pack_start(GTK_BOX(hbox44), start_seconds, TRUE, TRUE, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(start_seconds), TRUE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(start_seconds), TRUE); hbox45 = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox45); gtk_box_pack_start(GTK_BOX(hbox43), hbox45, TRUE, TRUE, 0); end_hours_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10); end_hours = gtk_spin_button_new(GTK_ADJUSTMENT(end_hours_adj), 1, 0); gtk_widget_show(end_hours); gtk_box_pack_start(GTK_BOX(hbox45), end_hours, TRUE, TRUE, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(end_hours), TRUE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(end_hours), TRUE); end_minutes_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10); end_minutes = gtk_spin_button_new(GTK_ADJUSTMENT(end_minutes_adj), 1, 0); gtk_widget_show(end_minutes); gtk_box_pack_start(GTK_BOX(hbox45), end_minutes, TRUE, TRUE, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(end_minutes), TRUE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(end_minutes), TRUE); end_seconds_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10); end_seconds = gtk_spin_button_new(GTK_ADJUSTMENT(end_seconds_adj), 1, 0); gtk_widget_show(end_seconds); gtk_box_pack_start(GTK_BOX(hbox45), end_seconds, TRUE, TRUE, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(end_seconds), TRUE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(end_seconds), TRUE); dialog_action_area4 = GTK_DIALOG(range_dialog)->action_area; gtk_widget_show(dialog_action_area4); gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area4), GTK_BUTTONBOX_END); cancel_button = gtk_button_new_from_stock("gtk-cancel"); gtk_widget_show(cancel_button); gtk_dialog_add_action_widget(GTK_DIALOG(range_dialog), cancel_button, GTK_RESPONSE_CANCEL); GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT); ok_button = gtk_button_new(); gtk_widget_show(ok_button); gtk_dialog_add_action_widget(GTK_DIALOG(range_dialog), ok_button, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT); alignment55 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment55); gtk_container_add(GTK_CONTAINER(ok_button), alignment55); hbox341 = gtk_hbox_new(FALSE, 2); gtk_widget_show(hbox341); gtk_container_add(GTK_CONTAINER(alignment55), hbox341); image49 = gtk_image_new_from_stock("gtk-ok", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image49); gtk_box_pack_start(GTK_BOX(hbox341), image49, FALSE, FALSE, 0); label97 = gtk_label_new_with_mnemonic(_("Select Time Range")); gtk_widget_show(label97); gtk_box_pack_start(GTK_BOX(hbox341), label97, FALSE, FALSE, 0); g_signal_connect((gpointer) start_hours, "value_changed", G_CALLBACK(cb_time_value_changed), NULL); g_signal_connect((gpointer) start_minutes, "value_changed", G_CALLBACK(cb_time_value_changed), NULL); g_signal_connect((gpointer) start_seconds, "value_changed", G_CALLBACK(cb_time_value_changed), NULL); g_signal_connect((gpointer) end_hours, "value_changed", G_CALLBACK(cb_time_value_changed), NULL); g_signal_connect((gpointer) end_minutes, "value_changed", G_CALLBACK(cb_time_value_changed), NULL); g_signal_connect((gpointer) end_seconds, "value_changed", G_CALLBACK(cb_time_value_changed), NULL); val = g_strdup_printf("%02d", 0); gtk_entry_set_text(GTK_ENTRY(start_hours), val); gtk_entry_set_text(GTK_ENTRY(start_minutes), val); gtk_entry_set_text(GTK_ENTRY(start_seconds), val); gtk_entry_set_text(GTK_ENTRY(end_hours), val); gtk_entry_set_text(GTK_ENTRY(end_minutes), val); gtk_entry_set_text(GTK_ENTRY(end_seconds), val); g_free(val); gtk_widget_grab_default(ok_button); return range_dialog; }
DateWidget::DateWidget(guint32 * seconds_since_epoch, bool showtime) /* By default this dialog shows the calendar only. If showtime is true it shows the time also. */ { // Store and initialize variabeles. my_seconds_since_epoch = seconds_since_epoch; setting_date_time = false; // Shortcuts. Shortcuts shortcuts(0); hbox = gtk_hbox_new(FALSE, 10); gtk_widget_show(hbox); vbox2 = gtk_vbox_new(FALSE, 0); gtk_widget_show(vbox2); gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0); label_date = gtk_label_new(_("Date")); gtk_widget_show(label_date); gtk_box_pack_start(GTK_BOX(vbox2), label_date, FALSE, FALSE, 0); gtk_misc_set_alignment(GTK_MISC(label_date), 0, 0.5); shortcuts.label(label_date); calendar1 = gtk_calendar_new(); gtk_widget_show(calendar1); gtk_box_pack_start(GTK_BOX(vbox2), calendar1, TRUE, TRUE, 0); gtk_calendar_display_options(GTK_CALENDAR(calendar1), GtkCalendarDisplayOptions(GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES | GTK_CALENDAR_SHOW_WEEK_NUMBERS)); label_time = NULL; if (showtime) { vseparator1 = gtk_vseparator_new(); gtk_widget_show(vseparator1); gtk_box_pack_start(GTK_BOX(hbox), vseparator1, TRUE, TRUE, 0); vbox1 = gtk_vbox_new(FALSE, 4); gtk_widget_show(vbox1); gtk_box_pack_start(GTK_BOX(hbox), vbox1, TRUE, TRUE, 0); label_time = gtk_label_new(_("Time")); gtk_widget_show(label_time); gtk_box_pack_start(GTK_BOX(vbox1), label_time, FALSE, FALSE, 0); gtk_misc_set_alignment(GTK_MISC(label_time), 0, 0.5); table1 = gtk_table_new(3, 2, FALSE); gtk_widget_show(table1); gtk_box_pack_start(GTK_BOX(vbox1), table1, FALSE, FALSE, 0); gtk_table_set_row_spacings(GTK_TABLE(table1), 8); gtk_table_set_col_spacings(GTK_TABLE(table1), 8); label_hour = gtk_label_new(_("Hour")); gtk_widget_show(label_hour); gtk_table_attach(GTK_TABLE(table1), label_hour, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label_hour), 1, 0.5); shortcuts.label(label_hour); label_minute = gtk_label_new(_("Minute")); gtk_widget_show(label_minute); gtk_table_attach(GTK_TABLE(table1), label_minute, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label_minute), 1, 0.5); shortcuts.label(label_minute); label_second = gtk_label_new(_("Second")); gtk_widget_show(label_second); gtk_table_attach(GTK_TABLE(table1), label_second, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label_second), 1, 0.5); shortcuts.label(label_second); spinbutton_minute_adj = gtk_adjustment_new(0, 0, 59, 1, 10, 0); spinbutton_minute = gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_minute_adj), 1, 0); gtk_widget_show(spinbutton_minute); gtk_table_attach(GTK_TABLE(table1), spinbutton_minute, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton_minute), TRUE); spinbutton_second_adj = gtk_adjustment_new(0, 0, 59, 1, 10, 0); spinbutton_second = gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_second_adj), 1, 0); gtk_widget_show(spinbutton_second); gtk_table_attach(GTK_TABLE(table1), spinbutton_second, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton_second), TRUE); spinbutton_hour_adj = gtk_adjustment_new(0, 0, 23, 1, 10, 0); spinbutton_hour = gtk_spin_button_new(GTK_ADJUSTMENT(spinbutton_hour_adj), 1, 0); gtk_widget_show(spinbutton_hour); gtk_table_attach(GTK_TABLE(table1), spinbutton_hour, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinbutton_hour), TRUE); } shortcuts.process(); g_signal_connect ((gpointer) calendar1, "day_selected", G_CALLBACK (on_calendar_changed), gpointer(this)); if (showtime) { g_signal_connect ((gpointer) spinbutton_minute, "changed", G_CALLBACK (on_spinbutton_changed), gpointer(this)); g_signal_connect ((gpointer) spinbutton_minute, "value_changed", G_CALLBACK (on_spinbutton_value_changed), gpointer(this)); g_signal_connect ((gpointer) spinbutton_second, "changed", G_CALLBACK (on_spinbutton_changed), gpointer(this)); g_signal_connect ((gpointer) spinbutton_second, "value_changed", G_CALLBACK (on_spinbutton_value_changed), gpointer(this)); g_signal_connect ((gpointer) spinbutton_hour, "changed", G_CALLBACK (on_spinbutton_changed), gpointer(this)); g_signal_connect ((gpointer) spinbutton_hour, "value_changed", G_CALLBACK (on_spinbutton_value_changed), gpointer(this)); } gtk_label_set_mnemonic_widget(GTK_LABEL(label_date), calendar1); if (showtime) { gtk_label_set_mnemonic_widget(GTK_LABEL(label_hour), spinbutton_hour); gtk_label_set_mnemonic_widget(GTK_LABEL(label_minute), spinbutton_minute); gtk_label_set_mnemonic_widget(GTK_LABEL(label_second), spinbutton_second); } // Set the date and optionally the time. set_date (); }