Skip to content

Commit

Permalink
Add some Widget just for testing
Browse files Browse the repository at this point in the history
These entries allow you to specify parameters for the calendar...
Start day Monday is 1 to Sunday 7
Start month 1 to 12
Year > 2000 < 2500

If view is changed it is best to renter month and year to UPDATE
  • Loading branch information
Bob-IT committed May 14, 2024
1 parent d87eb23 commit 917dc58
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions gnucash/gnome-utils/gnc-dense-cal.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,44 @@ struct _GncDenseCal
int disposed; /* private */
};

static void
_gdc_view_month_changed (GtkEntry *widget, gpointer user_data)
{
GncDenseCal *dcal = user_data;
const gchar *month = gtk_entry_get_text (widget);
gint imonth = atoi(month);

if (imonth > 0 && imonth < 13)
_gnc_dense_cal_set_month (dcal, imonth, TRUE);
}

static void
_gdc_view_year_changed (GtkEntry *widget, gpointer user_data)
{
GncDenseCal *dcal = user_data;
const gchar *year = gtk_entry_get_text (widget);
gint iyear = atoi(year);

if (iyear > 2000 && iyear < 2500)
_gnc_dense_cal_set_year (dcal, iyear, TRUE);
}

static void
_gdc_view_startday_changed (GtkEntry *widget, gpointer user_data)
{
GncDenseCal *dcal = user_data;
const gchar *startday = gtk_entry_get_text (widget);
gint istartday = atoi(startday);

if (istartday > 0 && istartday < 8)
{
dcal->day_of_week_start = istartday;
recompute_x_y_scales(dcal);
gnc_dense_cal_draw_to_buffer(dcal);
gtk_widget_queue_draw (GTK_WIDGET(dcal->cal_drawing_area));
}
}

typedef struct _gdc_mark_data
{
gchar *name;
Expand Down Expand Up @@ -330,6 +368,22 @@ gnc_dense_cal_init (GncDenseCal *dcal)
GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
GtkWidget *label = gtk_label_new (_("View"));

GtkWidget *year = gtk_entry_new();
GtkWidget *month = gtk_entry_new();
GtkWidget *startday = gtk_entry_new();

gtk_box_pack_start (GTK_BOX(hbox), GTK_WIDGET(month), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(hbox), GTK_WIDGET(year), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(hbox), GTK_WIDGET(startday), FALSE, FALSE, 0);

gtk_entry_set_placeholder_text (GTK_ENTRY(month), "Month");
gtk_entry_set_placeholder_text (GTK_ENTRY(year), "Year > 2000");
gtk_entry_set_placeholder_text (GTK_ENTRY(startday), "StartDay 1M-7S");

g_signal_connect(G_OBJECT(month), "changed", G_CALLBACK(_gdc_view_month_changed), (gpointer)dcal);
g_signal_connect(G_OBJECT(year), "changed", G_CALLBACK(_gdc_view_year_changed), (gpointer)dcal);
g_signal_connect(G_OBJECT(startday), "changed", G_CALLBACK(_gdc_view_startday_changed), (gpointer)dcal);

gtk_box_set_homogeneous (GTK_BOX(hbox), FALSE);
gtk_widget_set_halign (label, GTK_ALIGN_END);
gtk_widget_set_margin_end (label, 5);
Expand Down

0 comments on commit 917dc58

Please sign in to comment.