void click_sur_jour_calendrier_echeance ( GtkWidget *calendrier, gpointer null ) { time_t temps; time ( &temps ); g_signal_handlers_block_by_func ( G_OBJECT ( calendrier ), G_CALLBACK ( click_sur_jour_calendrier_echeance ), NULL ); if ( ( localtime ( &temps ) -> tm_mon == GTK_CALENDAR ( scheduled_calendar ) -> month ) && ( ( localtime ( &temps ) -> tm_year + 1900 ) == GTK_CALENDAR ( scheduled_calendar ) -> year ) ) gtk_calendar_select_day ( GTK_CALENDAR ( scheduled_calendar ), localtime ( &temps ) -> tm_mday ); else gtk_calendar_select_day ( GTK_CALENDAR ( scheduled_calendar ), FALSE ); g_signal_handlers_unblock_by_func ( G_OBJECT ( calendrier ), G_CALLBACK ( click_sur_jour_calendrier_echeance ), NULL ); }
void FormAccount_CursorChanged(GtkTreeView* treeview, gpointer user_data) { GtkTreePath* treepath; FormAccount* fa = (FormAccount*) user_data; GtkTreeModel* model; GtkTreeIter iter; gchar* OperationID; gchar* DateStr; guint DateYear; guint DateMonth; guint DateDay; gchar* DateStr1; gchar* DateStr2; gchar* Description; gdouble Money; guint Category; gchar Buf[50]; model = gtk_tree_view_get_model(treeview); gtk_tree_view_get_cursor(GTK_TREE_VIEW(fa->ListViewAccount), &treepath, NULL); gtk_tree_model_get_iter(model, &iter, treepath); gtk_tree_model_get(model, &iter, COL_ID_OPERATION_ID, &OperationID, COL_ID_DATE, &DateStr, COL_ID_DESCRIPTION, &Description, COL_ID_MONEY, &Money, COL_ID_CATEGORY_ID, &Category, -1); if (DateStr != NULL && DateStrToDMY(DateStr, &DateYear, &DateMonth, &DateDay) != -1) { fa->CalendarDateOnSelectEnabled = FALSE; gtk_calendar_select_day(GTK_CALENDAR(fa->CalendarDate), 0); gtk_calendar_select_month(GTK_CALENDAR(fa->CalendarDate), DateMonth-1, DateYear); gtk_calendar_select_day(GTK_CALENDAR(fa->CalendarDate), DateDay); fa->CalendarDateOnSelectEnabled = TRUE; } gtk_entry_set_text(GTK_ENTRY(fa->EntryDescription), Description != NULL ? Description : ""); sprintf(Buf, "%.2f", Money); gtk_entry_set_text(GTK_ENTRY(fa->EntryMoney), Buf); gtk_tree_path_free(treepath); if (OperationID != NULL) g_free(OperationID); if (DateStr != NULL) g_free(DateStr); if (Description != NULL) g_free(Description); }
/** * update the calendar of the scheduled transactions * * \param * * \return FALSE * */ gboolean gsb_calendar_update ( void ) { time_t temps; GSList *tmp_list; gint calendar_month; gint calendar_year; gtk_calendar_clear_marks ( GTK_CALENDAR ( scheduled_calendar )); /* select the current day */ time ( &temps ); if ( ( localtime ( &temps ) -> tm_mon == GTK_CALENDAR ( scheduled_calendar ) -> month ) && ( ( localtime ( &temps ) -> tm_year + 1900 ) == GTK_CALENDAR ( scheduled_calendar ) -> year ) ) gtk_calendar_select_day ( GTK_CALENDAR ( scheduled_calendar ), localtime ( &temps ) -> tm_mday ); else gtk_calendar_select_day ( GTK_CALENDAR ( scheduled_calendar ), FALSE ); calendar_month = GTK_CALENDAR ( scheduled_calendar ) -> month + 1; calendar_year = GTK_CALENDAR ( scheduled_calendar ) -> year + 25; /* check the scheduled transactions and bold them in the calendar */ tmp_list = gsb_data_scheduled_get_scheduled_list (); while ( tmp_list ) { GDate *tmp_date; gint scheduled_number; scheduled_number = gsb_data_scheduled_get_scheduled_number (tmp_list -> data); tmp_date = gsb_date_copy (gsb_data_scheduled_get_date (scheduled_number)); while (tmp_date && g_date_get_month (tmp_date) == calendar_month && g_date_get_year (tmp_date) < calendar_year) { GDate *new_date; gtk_calendar_mark_day ( GTK_CALENDAR ( scheduled_calendar ), g_date_get_day (tmp_date)); new_date = gsb_scheduler_get_next_date (scheduled_number, tmp_date); g_free (tmp_date); tmp_date = new_date; } tmp_list = tmp_list -> next; } return FALSE; }
static void log_window_chats_get_messages (EmpathyLogWindow *window, const gchar *date_to_show) { TpAccount *account; gchar *chat_id; gboolean is_chatroom; const gchar *date; guint year_selected; guint year; guint month; guint month_selected; guint day; if (!log_window_chats_get_selected (window, &account, &chat_id, &is_chatroom)) { return; } g_signal_handlers_block_by_func (window->calendar_chats, log_window_calendar_chats_day_selected_cb, window); /* Either use the supplied date or get the last */ date = date_to_show; if (!date) { /* Get a list of dates and show them on the calendar */ tpl_log_manager_get_dates_async (window->log_manager, account, chat_id, is_chatroom, log_manager_got_dates_cb, (gpointer) window); /* signal unblocked at the end of the CB flow */ } else { sscanf (date, "%4d%2d%2d", &year, &month, &day); gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats), &year_selected, &month_selected, NULL); month_selected++; if (year != year_selected && month != month_selected) { day = 0; } gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), day); g_signal_handlers_unblock_by_func (window->calendar_chats, log_window_calendar_chats_day_selected_cb, window); } if (date) { log_window_get_messages_for_date (window, date); } g_object_unref (account); g_free (chat_id); }
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(); }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkCalendar_gtk_1calendar_1select_1day ( JNIEnv* env, jclass cls, jlong _self, jint _day ) { GtkCalendar* self; guint day; // convert parameter self self = (GtkCalendar*) _self; // convert parameter day day = (guint) _day; // call function gtk_calendar_select_day(self, day); // cleanup parameter self // cleanup parameter day }
static void today_clicked (GtkWidget *cal) { GDateTime *now = g_date_time_new_now_local (); gtk_calendar_select_month ( GTK_CALENDAR(cal), g_date_time_get_month(now)-1, g_date_time_get_year(now) ); gtk_calendar_select_day ( GTK_CALENDAR(cal), g_date_time_get_day_of_month(now) ); g_date_time_unref ( now ); }
static update_dates(gpointer data) { guint year = ((NEW_DATA *) data)->newrun->year; guint month = ((NEW_DATA *) data)->newrun->month; gchar month_str[3]; g_snprintf(month_str, 3, "%i", month); guint day = ((NEW_DATA *) data)->newrun->day; GtkCalendar *calendar = ((NEW_DATA*) data)->calendar; GtkSpinButton *day_chooser = ((NEW_DATA*) data)->day_chooser; GtkComboBoxText *month_chooser = ((NEW_DATA*) data)->month_chooser; GtkSpinButton *year_chooser = ((NEW_DATA*) data)->year_chooser; gtk_spin_button_set_value(GTK_SPIN_BUTTON(day_chooser), day); gtk_spin_button_update(day_chooser); gtk_combo_box_set_active_id(GTK_COMBO_BOX(month_chooser), month_str); gtk_spin_button_set_value(GTK_SPIN_BUTTON(year_chooser), year); gtk_spin_button_update(year_chooser); gtk_calendar_select_day(GTK_CALENDAR(calendar), day); gtk_calendar_select_month(GTK_CALENDAR(calendar), month, year); //printf("%i/%i/%i\n", month, day, year); }
void Calendar::_change(int year_offset, int month_offset, int day_offset) { int year, month, day; gtk_calendar_get_date((GtkCalendar*)widget, (guint*)&year, (guint*)&month, (guint*)&day); unsigned int n_days = _n_days(year, month); day += day_offset; if (day < 1) { day += _n_days(year, month - 1); month_offset--; } else if (day > n_days) { day -= n_days; month_offset++; } month += month_offset; if (month > 11) { month = 0; year_offset++; } else if (month < 0) { month = 11; year_offset--; } year += year_offset; gtk_calendar_select_month((GtkCalendar*)widget, (guint)month, (guint)year); gtk_calendar_select_day((GtkCalendar*)widget, day); }
void DateWidget::set_date () { // Flags. setting_date_time = true; // Set the date. guint year, month, day; date_time_normal_get_year_month_day(date_time_seconds_to_julian(*my_seconds_since_epoch), year, month, day); gtk_calendar_select_month(GTK_CALENDAR(calendar1), month - 1, year); gtk_calendar_select_day(GTK_CALENDAR(calendar1), day); // And the time. if (label_time) { unsigned int seconds_in_day = (*my_seconds_since_epoch) % 86400; unsigned int hour = seconds_in_day / 3600; unsigned int remaining_seconds = seconds_in_day - (3600 * hour); unsigned int minute = remaining_seconds / 60; unsigned int second = remaining_seconds % 60; gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_minute), minute); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_second), second); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_hour), hour); } // Flags down. setting_date_time = false; }
/** * \brief Update Time controller widgets * \param mod Pointer to the GtkSatModule widget */ void tmg_update_widgets(GtkSatModule * mod) { struct tm tim; time_t t; /* update time widgets */ t = (mod->tmgCdnum - 2440587.5) * 86400.; if (sat_cfg_get_bool(SAT_CFG_BOOL_USE_LOCAL_TIME)) tim = *localtime(&t); else tim = *gmtime(&t); /* hour, min, sec, msec */ gtk_spin_button_set_value(GTK_SPIN_BUTTON(mod->tmgHour), tim.tm_hour); gtk_spin_button_set_value(GTK_SPIN_BUTTON(mod->tmgMin), tim.tm_min); gtk_spin_button_set_value(GTK_SPIN_BUTTON(mod->tmgSec), tim.tm_sec); /* msec: alway 0 in RT and SRT modes */ gtk_spin_button_set_value(GTK_SPIN_BUTTON(mod->tmgMsec), 0); /* calendar */ gtk_calendar_select_month(GTK_CALENDAR(mod->tmgCal), tim.tm_mon, tim.tm_year + 1900); gtk_calendar_select_day(GTK_CALENDAR(mod->tmgCal), tim.tm_mday); }
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(); }
G_MODULE_EXPORT void on_today_clicked (GtkButton *widget, gpointer arg) { GDate date; GtkStuff *stuff = (GtkStuff*) (arg); g_date_set_time_t (&date, time (NULL)); gtk_calendar_select_month (stuff->calendar, g_date_get_month (&date) - 1, g_date_get_year (&date)); gtk_calendar_select_day (stuff->calendar, g_date_get_day (&date)); on_calendar1_day_selected (stuff->calendar, stuff); }
int get_date(GtkWidget *t, isoDate_t *date) { GtkWidget *w; GtkWindow *win; GtkWidget *thiswin; gint x,x_off; gint y,y_off; guint year; guint month; guint day; isoDate_t odate=*date; got_date=0; win=GTK_WINDOW(gtk_builder_get_object (builder, "CalendarWindow")); if(win==NULL) { fprintf(stderr,"Could not locate Calendar window\n"); return(-1); } thiswin = gtk_widget_get_toplevel(t); if(thiswin==NULL) { fprintf(stderr,"Could not locate main window\n"); return(-1); } if(!(gtk_widget_translate_coordinates(GTK_WIDGET(t) ,GTK_WIDGET(thiswin), 0, 0, &x_off, &y_off))) { fprintf(stderr,"Could not get position of button in window"); } gtk_window_get_position(GTK_WINDOW(thiswin), &x, &y); gtk_window_move(GTK_WINDOW(win), x+x_off, y+y_off); w=GTK_WIDGET(gtk_builder_get_object (builder, "Calendar")); if(w==NULL) { fprintf(stderr,"Could not locate Calendar widget\n"); return(-1); } gtk_calendar_select_month(GTK_CALENDAR(w), isoDate_month(*date)-1, isoDate_year(*date)); gtk_calendar_select_day(GTK_CALENDAR(w), isoDate_day(*date)); gtk_window_present(GTK_WINDOW(win)); /* Wait for window to close... */ gtk_main(); w=GTK_WIDGET(gtk_builder_get_object (builder, "Calendar")); if(w==NULL) return(-1); gtk_calendar_get_date(GTK_CALENDAR(w), &year, &month, &day); gtk_widget_hide_on_delete(GTK_WIDGET(gtk_widget_get_toplevel(GTK_WIDGET(w)))); *date=isoDate_create(year, month+1, day); return(odate!=*date); }
/* Selects a day from the current month. */ int clip_GTK_CALENDARSELECTDAY(ClipMachine * ClipMachineMemory) { C_widget *ccal = _fetch_cw_arg(ClipMachineMemory); guint day = _clip_parni(ClipMachineMemory, 2); CHECKCWID(ccal, GTK_IS_CALENDAR); CHECKOPT(2, NUMERIC_type_of_ClipVarType); gtk_calendar_select_day(GTK_CALENDAR(ccal->widget), day); return 0; err: return 1; }
static void gnc_date_edit_set_time_internal (GNCDateEdit *gde, time64 the_time) { char buffer [40]; struct tm *mytm = gnc_localtime (&the_time); g_return_if_fail(mytm != NULL); /* Update the date text. */ qof_print_date_dmy_buff(buffer, 40, mytm->tm_mday, mytm->tm_mon + 1, 1900 + mytm->tm_year); gtk_entry_set_text(GTK_ENTRY(gde->date_entry), buffer); /* Update the calendar. */ if (!gde->in_selected_handler) { gtk_calendar_select_day(GTK_CALENDAR (gde->calendar), 1); gtk_calendar_select_month(GTK_CALENDAR (gde->calendar), mytm->tm_mon, 1900 + mytm->tm_year); gtk_calendar_select_day(GTK_CALENDAR (gde->calendar), mytm->tm_mday); } /* Set the time of day. */ if (gde->flags & GNC_DATE_EDIT_24_HR) qof_strftime (buffer, sizeof (buffer), "%H:%M", mytm); else qof_strftime (buffer, sizeof (buffer), "%I:%M %p", mytm); gtk_entry_set_text(GTK_ENTRY(gde->time_entry), buffer); gnc_tm_free (mytm); g_signal_emit (gde, date_edit_signals [DATE_CHANGED], 0); g_signal_emit (gde, date_edit_signals [TIME_CHANGED], 0); }
static void SetCalendar( GtkWidget *widget, WidgetData *wdata, _Calendar *data) { ENTER_FUNC; SetCommon(widget,wdata); if (data->year > 0) { gtk_calendar_select_month(GTK_CALENDAR(widget), data->month - 1, data->year); gtk_calendar_select_day(GTK_CALENDAR(widget),data->day); } LEAVE_FUNC; }
static void gcrd_today_clicked (GtkWidget *button, GncCellRendererDate *cell) { time64 today; gint year, month, day; today = gnc_time (NULL); gcrd_time2dmy ( today, &day, &month, &year); gtk_calendar_clear_marks (GTK_CALENDAR (cell->calendar)); gtk_calendar_select_month (GTK_CALENDAR (cell->calendar), month - 1, year); gtk_calendar_select_day (GTK_CALENDAR (cell->calendar), day); gtk_calendar_mark_day (GTK_CALENDAR (cell->calendar), day); }
void set_date_time(struct tm dt) { GtkWidget *calendar = lookup_widget(MainWindow,"calendar1"); GtkWidget *hour = lookup_widget(MainWindow,"spinbutton1"); GtkWidget *minute = lookup_widget(MainWindow,"spinbutton2"); GtkWidget *second = lookup_widget(MainWindow,"spinbutton3"); set_time(dt); gtk_spin_button_set_value(GTK_SPIN_BUTTON(hour),(gdouble) dt.tm_hour); gtk_spin_button_set_value(GTK_SPIN_BUTTON(minute),(gdouble) dt.tm_min); gtk_spin_button_set_value(GTK_SPIN_BUTTON(second),(gdouble) dt.tm_sec); gtk_calendar_select_month(GTK_CALENDAR(calendar), dt.tm_mon,dt.tm_year + 1900); gtk_calendar_select_day(GTK_CALENDAR(calendar), dt.tm_mday); }
static void calendar_update(GtkWidget *calendar, gint add) { static const gint month_length[2][13] = { { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; gint day, month; guint year; gint days_in_month; gboolean leap_year; gtk_calendar_get_date(GTK_CALENDAR(calendar), &year, (guint*)&month, (guint*)&day); leap_year = g_date_is_leap_year(year); days_in_month = month_length[leap_year][month+1]; if (add != 0) { day += add; if (day < 1) { day = (month_length[leap_year][month]) + day; month--; } else if (day > days_in_month) { day -= days_in_month; month++; } if (month < 0) { year--; leap_year = g_date_is_leap_year(year); month = 11; day = month_length[leap_year][month+1]; } else if (month > 11) { year++; leap_year = g_date_is_leap_year(year); month = 0; day = 1; } } gtk_calendar_select_month(GTK_CALENDAR(calendar), month, year); gtk_calendar_select_day(GTK_CALENDAR(calendar), day); }
static void gtk_dateentry_popup_display (GtkDateEntry * dateentry) { const char *str; int month; //gint height, width, x, y; gint old_width, old_height; DB( g_print(" (dateentry) popup_display\n****\n\n") ); old_width = dateentry->popwin->allocation.width; old_height = dateentry->popwin->allocation.height; /* update */ str = gtk_entry_get_text (GTK_ENTRY (dateentry->entry)); g_date_set_parse (dateentry->date, str); if(g_date_valid(dateentry->date) == TRUE) { /* GtkCalendar expects month to be in 0-11 range (inclusive) */ month = g_date_get_month (dateentry->date) - 1; gtk_calendar_select_month (GTK_CALENDAR (dateentry->calendar), CLAMP (month, 0, 11), g_date_get_year (dateentry->date)); gtk_calendar_select_day (GTK_CALENDAR (dateentry->calendar), g_date_get_day (dateentry->date)); } position_popup(dateentry); gtk_widget_show (dateentry->popwin); gtk_grab_add (dateentry->popwin); // this close the popup */ gdk_pointer_grab (dateentry->popwin->window, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, NULL, NULL, GDK_CURRENT_TIME); }
static void gcrd_show (GncCellRendererPopup *cell, const gchar *path, gint x1, gint y1, gint x2, gint y2) { GncCellRendererDate *date; gint year; gint month; gint day; gint index; const gchar *text; if (parent_class->show_popup) { parent_class->show_popup (cell, path, x1, y1, x2, y2); } date = GNC_CELL_RENDERER_DATE (cell); text = gnc_popup_entry_get_text (GNC_POPUP_ENTRY (GNC_CELL_RENDERER_POPUP (cell)->editable)); if (!(g_strcmp0(text, ""))) { date->time = gnc_time (NULL); gcrd_time2dmy ( date->time, &day, &month, &year); } else { date->time = gcrd_string_dmy2time (text); gcrd_time2dmy ( date->time, &day, &month, &year); } gtk_calendar_clear_marks (GTK_CALENDAR (date->calendar)); gtk_calendar_select_month (GTK_CALENDAR (date->calendar), month - 1, year); gtk_calendar_select_day (GTK_CALENDAR (date->calendar), day); gtk_calendar_mark_day (GTK_CALENDAR (date->calendar), day); }
static void update_calendar (TpawCalendarButton *self) { if (self->priv->calendar == NULL) return; gtk_calendar_clear_marks (GTK_CALENDAR (self->priv->calendar)); if (self->priv->date == NULL) return; gtk_calendar_select_day (GTK_CALENDAR (self->priv->calendar), g_date_get_day (self->priv->date)); gtk_calendar_select_month (GTK_CALENDAR (self->priv->calendar), g_date_get_month (self->priv->date) - 1, g_date_get_year (self->priv->date)); gtk_calendar_mark_day (GTK_CALENDAR (self->priv->calendar), g_date_get_day (self->priv->date)); }
void seahorse_gpgme_expires_new (SeahorseGpgmeSubkey *subkey, GtkWindow *parent) { SeahorseWidget *swidget; GtkWidget *date, *expire; gulong expires; gchar *title; const gchar *label; g_return_if_fail (subkey != NULL && SEAHORSE_IS_GPGME_SUBKEY (subkey)); swidget = seahorse_widget_new_allow_multiple ("expires", parent); g_return_if_fail (swidget != NULL); g_object_set_data_full (G_OBJECT (swidget), "subkey", g_object_ref (subkey), g_object_unref); date = GTK_WIDGET (seahorse_widget_get_widget (swidget, "calendar")); g_return_if_fail (date != NULL); expire = GTK_WIDGET (seahorse_widget_get_widget (swidget, "expire")); expires = seahorse_pgp_subkey_get_expires (SEAHORSE_PGP_SUBKEY (subkey)); if (!expires) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (expire), TRUE); gtk_widget_set_sensitive (date, FALSE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (expire), FALSE); gtk_widget_set_sensitive (date, TRUE); } if (expires) { struct tm t; time_t time = (time_t)expires; if (gmtime_r (&time, &t)) { gtk_calendar_select_month (GTK_CALENDAR (date), t.tm_mon, t.tm_year + 1900); gtk_calendar_select_day (GTK_CALENDAR (date), t.tm_mday); } } label = seahorse_pgp_subkey_get_description (SEAHORSE_PGP_SUBKEY (subkey)); title = g_strdup_printf (_("Expiry: %s"), label); gtk_window_set_title (GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name)), title); g_free (title); }
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(); }
/** * a_dialog_get_date: * * Returns: a date as a string - always in ISO8601 format (YYYY-MM-DD) * This string can be NULL (especially when the dialog is cancelled) * Free the string after use */ gchar *a_dialog_get_date ( GtkWindow *parent, const gchar *title ) { GtkWidget *dialog = gtk_dialog_new_with_buttons ( title, parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); GtkWidget *cal = gtk_calendar_new (); GtkWidget *today = gtk_button_new_with_label ( _("Today") ); static guint year = 0; static guint month = 0; static guint day = 0; if ( year != 0 ) { // restore the last selected date gtk_calendar_select_month ( GTK_CALENDAR(cal), month, year ); gtk_calendar_select_day ( GTK_CALENDAR(cal), day ); } gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), today, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), cal, FALSE, FALSE, 0); g_signal_connect_swapped ( G_OBJECT(today), "clicked", G_CALLBACK(today_clicked), cal ); gtk_widget_show_all ( dialog ); gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); gchar *date_str = NULL; if ( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT ) { gtk_calendar_get_date ( GTK_CALENDAR(cal), &year, &month, &day ); date_str = g_strdup_printf ( "%d-%02d-%02d", year, month+1, day ); } gtk_widget_destroy ( dialog ); return date_str; }
static gboolean on_visibility_notify(GtkWidget* widget, GdkEvent* event, gpointer data) { GDateTime* datetime = g_date_time_new_now_local(); if(!datetime) { gtk_menu_item_set_label(GTK_MENU_ITEM(greeter.ui.clock.date_widget), "[date]"); g_signal_handler_disconnect(greeter.ui.clock.date_widget, visibility_notify_id); return TRUE; } gchar* str = g_date_time_format(datetime, config.clock.date_format); gtk_menu_item_set_label(GTK_MENU_ITEM(greeter.ui.clock.date_widget), str); gtk_calendar_select_month(GTK_CALENDAR(greeter.ui.clock.calendar_widget), g_date_time_get_month(datetime) - 1, g_date_time_get_year(datetime)); gtk_calendar_select_day(GTK_CALENDAR(greeter.ui.clock.calendar_widget), g_date_time_get_day_of_month(datetime)); g_free(str); g_date_time_unref(datetime); return TRUE; }
static void on_calendar_entry_activated(GtkWidget *widget, GtkWidget *calendar) { GDate *date; const gchar *text; date = g_date_new(); text = gtk_entry_get_text(GTK_ENTRY(widget)); g_date_set_parse(date, text); if (g_date_valid(date)) { gtk_calendar_freeze(GTK_CALENDAR(calendar)); gtk_calendar_select_month(GTK_CALENDAR(calendar), g_date_get_month(date) - 1, g_date_get_year(date)); gtk_calendar_select_day(GTK_CALENDAR(calendar), g_date_get_day(date)); gtk_calendar_thaw(GTK_CALENDAR(calendar)); } g_date_free(date); }
void on_buttonCalendar_clicked( GtkWidget *widget, struct _properties *properties ) { g_print ("on_buttonCalendar_clicked():\n"); gtk_window_set_title(GTK_WINDOW(properties->GtkInfo.dialogCalendar), "Select Date for Expr"); gtk_window_set_icon(GTK_WINDOW(properties->GtkInfo.dialogCalendar), create_pixbuf("images/2.png")); int year; int month; int day; int hour; int minute; int seconds; properties->calendarSelected = 0; decimal_date_to_real_dates(properties->data.t[properties->calendarSelected], &year, &month, &day, &hour, &minute, &seconds); gtk_calendar_select_month(GTK_CALENDAR(properties->GtkInfo.calendar1), month, year); gtk_calendar_select_day(GTK_CALENDAR(properties->GtkInfo.calendar1), day); gtk_dialog_run(GTK_DIALOG(properties->GtkInfo.dialogCalendar)); }
bool wxGtkCalendarCtrl::SetDate(const wxDateTime& date) { if ( date.IsValid() && !IsInValidRange(date) ) return false; g_signal_handlers_block_by_func(m_widget, (gpointer) gtk_day_selected_callback, this); g_signal_handlers_block_by_func(m_widget, (gpointer) gtk_month_changed_callback, this); m_selectedDate = date; int year = date.GetYear(); int month = date.GetMonth(); int day = date.GetDay(); gtk_calendar_select_month(GTK_CALENDAR(m_widget), month, year); gtk_calendar_select_day(GTK_CALENDAR(m_widget), day); g_signal_handlers_unblock_by_func( m_widget, (gpointer) gtk_month_changed_callback, this); g_signal_handlers_unblock_by_func( m_widget, (gpointer) gtk_day_selected_callback, this); return true; }