From f8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 11 Dec 2015 20:37:59 -0500 Subject: LET'S GET THIS FINAL REWRITE EVER STARTED --- gtkdtp/dtp.c | 140 -------------------------- gtkdtp/dtp.h | 21 ---- gtkdtp/mockup.ui | 299 ------------------------------------------------------- gtkdtp/test.c | 16 --- 4 files changed, 476 deletions(-) delete mode 100644 gtkdtp/dtp.c delete mode 100644 gtkdtp/dtp.h delete mode 100644 gtkdtp/mockup.ui delete mode 100644 gtkdtp/test.c (limited to 'gtkdtp') diff --git a/gtkdtp/dtp.c b/gtkdtp/dtp.c deleted file mode 100644 index 70876bd..0000000 --- a/gtkdtp/dtp.c +++ /dev/null @@ -1,140 +0,0 @@ -// 9 january 2015 -#include "dtp.h" - -/* notes: -https://git.gnome.org/browse/gtk+/tree/gtk/gtkcombobox.c?h=gtk-3-4 -*/ - -#define GDTP(x) ((goDateTimePicker *) x) -#define PRIV(x) (GDTP(x)->priv) -#define GDTPC(x) ((goDateTimePickerClass *) x) - -struct goDateTimePickerPrivate { - gint year; - gint month; - gint day; -}; - -G_DEFINE_TYPE_WITH_CODE(goDateTimePicker, goDateTimePicker, GTK_TYPE_BOX, - ;) - -// TODO figure out how to share these between C and Go -enum { - gtkMargin = 12, - gtkXPadding = 12, - gtkYPadding = 6, -}; - -static void goDateTimePicker_init(goDateTimePicker *dtp) -{ - dtp->priv = G_TYPE_INSTANCE_GET_PRIVATE(dtp, goDateTimePicker_get_type(), goDateTimePickerPrivate); -} - -static void goDateTimePicker_dispose(GObject *obj) -{ - goDateTimePickerPrivate *d = PRIV(obj); - - // TODO really with g_clear_object()? - G_OBJECT_CLASS(goDateTimePicker_parent_class)->dispose(obj); -} - -static void goDateTimePicker_finalize(GObject *obj) -{ - G_OBJECT_CLASS(goDateTimePicker_parent_class)->finalize(obj); -} - -enum { - pYear = 1, - pMonth, - pDay, - nParams, -}; - -static GParamSpec *gdtpParams[] = { - NULL, // always null - NULL, // year - NULL, // month - NULL, // day -}; - -static void goDateTimePicker_set_property(GObject *obj, guint prop, const GValue *value, GParamSpec *spec) -{ - goDateTimePickerPrivate *d = PRIV(obj); - - switch (prop) { - case pYear: - d->year = g_value_get_int(value); - break; - case pMonth: - d->month = g_value_get_int(value); - break; - case pDay: - d->day = g_value_get_int(value); - // see note on GtkCalendar comaptibility below - if (d->day == 0) - ; // TODO - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop, spec); - return; - } - // TODO refresh everything here -} - -static void goDateTimePicker_get_property(GObject *obj, guint prop, GValue *value, GParamSpec *spec) -{ - goDateTimePickerPrivate *d = PRIV(obj); - - switch (prop) { - case pYear: - g_value_set_int(value, d->year); - break; - case pMonth: - g_value_set_int(value, d->month); - break; - case pDay: - g_value_set_int(value, d->day); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop, spec); - return; - } -} - -static void goDateTimePicker_class_init(goDateTimePickerClass *class) -{ - g_type_class_add_private(class, sizeof (goDateTimePickerPrivate)); - - G_OBJECT_CLASS(class)->dispose = goDateTimePicker_dispose; - G_OBJECT_CLASS(class)->finalize = goDateTimePicker_finalize; - G_OBJECT_CLASS(class)->set_property = goDateTimePicker_set_property; - G_OBJECT_CLASS(class)->get_property = goDateTimePicker_get_property; - - // types and values are to be compatible with the 3.4 GtkCalendar parameters - gdtpParams[pYear] = g_param_spec_int("year", - "current year", - "Current year", - 0, - G_MAXINT >> 9, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - gdtpParams[pMonth] = g_param_spec_uint("month", - "current month", - "Current month", - 0, - 11, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - // because of the requirement to be compatible with GtkCalendar, we have to follow its rules about dates - // values are 1..31 with 0 meaning no date selected - // we will not allow no date to be selected, so we will set the default to 1 instead of 0 - // TODO is this an issue for binding? - gdtpParams[pDay] = g_param_spec_uint("day", - "current day", - "Current day", - 0, - 31, - 1, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_properties(G_OBJECT_CLASS(class), nParams, gdtpParams); -} diff --git a/gtkdtp/dtp.h b/gtkdtp/dtp.h deleted file mode 100644 index 3c936c6..0000000 --- a/gtkdtp/dtp.h +++ /dev/null @@ -1,21 +0,0 @@ -// 9 january 2015 -#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_32 -#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_32 -#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_4 -#define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_4 -#include - -typedef struct goDateTimePicker goDateTimePicker; -typedef struct goDateTimePickerClass goDateTimePickerClass; -typedef struct goDateTimePickerPrivate goDateTimePickerPrivate; - -struct goDateTimePicker { - GtkBox parent_instance; - goDateTimePickerPrivate *priv; -}; - -struct goDateTimePickerClass { - GtkBoxClass parent_class; -}; - -GType goDateTimePicker_get_type(void); diff --git a/gtkdtp/mockup.ui b/gtkdtp/mockup.ui deleted file mode 100644 index ebd12d8..0000000 --- a/gtkdtp/mockup.ui +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - 1 - 12 - 1 - 10 - - - 59 - 1 - 10 - - - False - - - True - False - 12 - 12 - 12 - 12 - 12 - - - True - False - vertical - - - True - False - Unopened - - - False - True - 0 - - - - - True - False - True - - - False - 10 Jan 2015 7:01 PM - - - - - False - True - 1 - - - - - True - False - Each component of the date/time string is a clickable item; free-form text cannot be entered. Clicking an item selects it; typing and the arrow keys change the values. Right clicking produces a Copy item and possibly an Undo item; the standard keyboard shortcuts will also work. - True - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - False - vertical - - - True - False - Opened - - - False - True - 0 - - - - - True - False - True - - - False - 10 Jan 2015 7:01 PM - - - - - False - True - 1 - - - - - True - False - 0 - out - - - True - False - 12 - 12 - 12 - 12 - vertical - 6 - - - True - True - 2015 - 10 - - - False - True - 0 - - - - - True - False - - - True - True - adjustment1 - 7 - - - False - True - 0 - - - - - True - False - : - - - False - True - 1 - - - - - True - True - adjustment2 - 1 - - - False - True - 2 - - - - - True - False - 1 - - AM - PM - - - - False - True - 3 - - - - - False - True - 1 - - - - - True - False - end - 6 - True - - - Today - True - True - True - - - False - True - 0 - - - - - Revert - True - True - True - - - False - True - 1 - - - - - False - False - end - 2 - - - - - - - - - - False - True - 2 - - - - - True - False - The combobox part works exactly like in the unopened mode. When opened, the popup shows a calendar, more conventional time editing, and buttons to select the current date/time and undo any changes made while the popup was open. Closing the popup (in the same way you would close a combobox popup) applies changes. -The label of the Today button changes depending on whether dates only, times only, or both can be chosen. - True - - - False - True - 3 - - - - - False - True - 2 - - - - - - diff --git a/gtkdtp/test.c b/gtkdtp/test.c deleted file mode 100644 index c867c11..0000000 --- a/gtkdtp/test.c +++ /dev/null @@ -1,16 +0,0 @@ -// 9 january 2015 -#include "dtp.h" - -// #qo pkg-config: gtk+-3.0 - -int main(void) -{ - GtkWidget *mainwin; - - gtk_init(NULL, NULL); - mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_container_add(GTK_CONTAINER(mainwin), g_object_new(goDateTimePicker_get_type(), NULL)); - gtk_widget_show_all(mainwin); - gtk_main(); - return 0; -} -- cgit v1.2.3