]> Pileus Git - ~andy/gtk/commitdiff
Add GTK_CALENDAR_SHOW_DETAILS display flag, which chooses if details are shown within...
authorMathias Hasselmann <hasselmm@src.gnome.org>
Fri, 28 Dec 2007 09:39:34 +0000 (09:39 +0000)
committerMathias Hasselmann <hasselmm@src.gnome.org>
Fri, 28 Dec 2007 09:39:34 +0000 (09:39 +0000)
* gtk/gtkcalendar.c, gtk/gtkcalendar.h: Add "show-details" property
aka. GTK_CALENDAR_SHOW_DETAILS, and use it.
* tests/testcalendar.c: Test GTK_CALENDAR_SHOW_DETAILS. Reduce padding
in flags vbox.

svn path=/trunk/; revision=19267

ChangeLog
docs/reference/ChangeLog
docs/reference/gtk/tmpl/gtkcalendar.sgml
gtk/gtkcalendar.c
gtk/gtkcalendar.h
tests/testcalendar.c

index e41f1e34ec8f7d813b29ba5da4adf25f050f6a72..7ae79a061014da0a1fc3e6ba0a84a3f078a69dce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-12-28  Mathias Hasselmann  <mathias@openismus.com>
+
+       Add GTK_CALENDAR_SHOW_DETAILS display flag, which chooses if details
+       are shown within the widget, or jst as tooltip.
+
+       * gtk/gtkcalendar.c, gtk/gtkcalendar.h: Add "show-details" property
+       aka. GTK_CALENDAR_SHOW_DETAILS, and use it.
+       * tests/testcalendar.c: Test GTK_CALENDAR_SHOW_DETAILS. Reduce padding
+       in flags vbox.
+
 2007-12-28  Mathias Hasselmann  <mathias@openismus.com>
 
        Try more decent appearance of calendar details separator. (#339540)
index b4f0c7ad32ed749d9a00920831269652dba987c8..d6d5105b838ca0398ec82ddb5a711955096a77ef 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-28  Mathias Hasselmann  <mathias@openismus.com>
+
+       * gtk/tmpl/gtkcalendar.sgml: Move documentation for
+       GtkCalendarDisplayOptions to gtk/gtkcalendar.c.
+
 2007-12-27  Mathias Hasselmann  <mathias@openismus.com>
 
        * reference/gtk/gtk-sections.txt: Add new GtkCalendar symbols.
index 3de3fb21dc6bf59ffc6d044a7d9567fe5b055810..bcac0b38aedfaad24401713edfbb0dee237f4111 100644 (file)
@@ -150,17 +150,8 @@ calendar.
 
 <!-- ##### ENUM GtkCalendarDisplayOptions ##### -->
 <para>
-These options can be used to influence the display and behaviour of a #GtkCalendar.
 </para>
 
-@GTK_CALENDAR_SHOW_HEADING: Specifies that the month and year should be displayed.
-@GTK_CALENDAR_SHOW_DAY_NAMES: Specifies that three letter day descriptions should be present.
-@GTK_CALENDAR_NO_MONTH_CHANGE: Prevents the user from switching months with the calendar.
-@GTK_CALENDAR_SHOW_WEEK_NUMBERS: Displays each week numbers of the current year, down the left side 
- of the calendar.
-@GTK_CALENDAR_WEEK_START_MONDAY: Since GTK+ 2.4, this option is deprecated and ignored by GTK+. 
- The information on which day the calendar week starts is derived from the locale.
-
 <!-- ##### FUNCTION gtk_calendar_new ##### -->
 <para>
 </para>
index 29d2a7b49d40f74774abe10ee95136fa9b5b5026..45cc8808809dd031855e89322802a8038aaf8ab6 100644 (file)
@@ -233,6 +233,7 @@ enum
   PROP_SHOW_DAY_NAMES,
   PROP_NO_MONTH_CHANGE,
   PROP_SHOW_WEEK_NUMBERS,
+  PROP_SHOW_DETAILS,
   PROP_DETAIL_WIDTH_CHARS,
   PROP_DETAIL_HEIGHT_ROWS,
   PROP_LAST
@@ -544,6 +545,23 @@ gtk_calendar_class_init (GtkCalendarClass *class)
                                                     0, 127, 0,
                                                     GTK_PARAM_READWRITE));
 
+/**
+ * GtkCalendar:show-details:
+ *
+ * Determines whether details are shown directly in the widget, or if they are
+ * available only as tooltip. When this property is set days with details are
+ * marked.
+ *
+ * Since: 2.16
+ */
+  g_object_class_install_property (gobject_class,
+                                   PROP_SHOW_DETAILS,
+                                   g_param_spec_boolean ("show-details",
+                                                        P_("Show Details"),
+                                                        P_("If TRUE, details are shown"),
+                                                        TRUE,
+                                                        GTK_PARAM_READWRITE));
+
   gtk_calendar_signals[MONTH_CHANGED_SIGNAL] =
     g_signal_new (I_("month_changed"),
                  G_OBJECT_CLASS_TYPE (gobject_class),
@@ -677,8 +695,9 @@ gtk_calendar_init (GtkCalendar *calendar)
   calendar->num_marked_dates = 0;
   calendar->selected_day = tm->tm_mday;
   
-  calendar->display_flags = ( GTK_CALENDAR_SHOW_HEADING | 
-                             GTK_CALENDAR_SHOW_DAY_NAMES );
+  calendar->display_flags = (GTK_CALENDAR_SHOW_HEADING |
+                            GTK_CALENDAR_SHOW_DAY_NAMES |
+                            GTK_CALENDAR_SHOW_DETAILS);
   
   calendar->highlight_row = -1;
   calendar->highlight_col = -1;
@@ -785,9 +804,9 @@ calendar_queue_refresh (GtkCalendar *calendar)
 {
   GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
 
-  if (!priv->detail_func ||
-       priv->detail_width_chars ||
-       priv->detail_height_rows)
+  if (!(priv->detail_func) ||
+      !(calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS) ||
+       (priv->detail_width_chars && priv->detail_height_rows))
     gtk_widget_queue_draw (GTK_WIDGET (calendar));
   else
     gtk_widget_queue_resize (GTK_WIDGET (calendar));
@@ -1295,6 +1314,11 @@ gtk_calendar_set_property (GObject      *object,
                                   GTK_CALENDAR_SHOW_WEEK_NUMBERS,
                                   g_value_get_boolean (value));
       break;
+    case PROP_SHOW_DETAILS:
+      calendar_set_display_option (calendar,
+                                  GTK_CALENDAR_SHOW_DETAILS,
+                                  g_value_get_boolean (value));
+      break;
     case PROP_DETAIL_WIDTH_CHARS:
       gtk_calendar_set_detail_width_chars (calendar,
                                            g_value_get_int (value));
@@ -1345,6 +1369,10 @@ gtk_calendar_get_property (GObject      *object,
       g_value_set_boolean (value, calendar_get_display_option (calendar,
                                                               GTK_CALENDAR_SHOW_WEEK_NUMBERS));
       break;
+    case PROP_SHOW_DETAILS:
+      g_value_set_boolean (value, calendar_get_display_option (calendar,
+                                                              GTK_CALENDAR_SHOW_DETAILS));
+      break;
     case PROP_DETAIL_WIDTH_CHARS:
       g_value_set_int (value, priv->detail_width_chars);
       break;
@@ -1672,7 +1700,8 @@ gtk_calendar_query_tooltip (GtkWidget  *widget,
       col = calendar_column_from_x (calendar, x - x0);
       row = calendar_row_from_y (calendar, y - y0);
 
-      if (priv->detail_overflow[row] & (1 << col))
+      if (0 != (priv->detail_overflow[row] & (1 << col)) ||
+          0 == (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS))
         {
           detail = gtk_calendar_get_detail (calendar, row, col);
           calendar_day_rectangle (calendar, row, col, &day_rect);
@@ -1826,7 +1855,7 @@ gtk_calendar_size_request (GtkWidget        *widget,
    * pango_layout_set_markup is called which alters font settings. */
   priv->max_detail_height = 0;
 
-  if (priv->detail_func)
+  if (priv->detail_func && (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS))
     {
       gchar *markup, *tail;
 
@@ -2389,13 +2418,15 @@ calendar_paint_day (GtkCalendar *calendar,
   PangoLayout *layout;
   PangoRectangle logical_rect;
   gboolean overflow = FALSE;
-  
+  gboolean show_details;
+
   g_return_if_fail (row < 6);
   g_return_if_fail (col < 7);
 
   cr = gdk_cairo_create (priv->main_win);
 
   day = calendar->day[row][col];
+  show_details = (calendar->display_flags & GTK_CALENDAR_SHOW_DETAILS);
 
   calendar_day_rectangle (calendar, row, col, &day_rect);
   
@@ -2457,13 +2488,13 @@ calendar_paint_day (GtkCalendar *calendar,
   
   x_loc = day_rect.x + (day_rect.width - logical_rect.width) / 2;
   y_loc = day_rect.y;
-  
+
   gdk_cairo_set_source_color (cr, text_color);
   cairo_move_to (cr, x_loc, y_loc);
   pango_cairo_show_layout (cr, layout);
-    
-  if (calendar->marked_date[day-1]
-      && calendar->day_month[row][col] == MONTH_CURRENT)
+
+  if (calendar->day_month[row][col] == MONTH_CURRENT &&
+     (calendar->marked_date[day-1] || (detail && !show_details)))
     {
       cairo_move_to (cr, x_loc - 1, y_loc);
       pango_cairo_show_layout (cr, layout);
@@ -2471,7 +2502,7 @@ calendar_paint_day (GtkCalendar *calendar,
 
   y_loc += priv->max_day_char_descent;
 
-  if (priv->detail_func)
+  if (priv->detail_func && show_details)
     {
       cairo_save (cr);
 
@@ -2492,7 +2523,7 @@ calendar_paint_day (GtkCalendar *calendar,
       y_loc += 2;
     }
 
-  if (detail)
+  if (detail && show_details)
     {
       gint i, n_lines;
 
@@ -3617,6 +3648,9 @@ gtk_calendar_set_display_options (GtkCalendar            *calendar,
       if ((flags ^ calendar->display_flags) & GTK_CALENDAR_WEEK_START_MONDAY)
        g_warning ("GTK_CALENDAR_WEEK_START_MONDAY is ignored; the first day of the week is determined from the locale");
       
+      if ((flags ^ calendar->display_flags) & GTK_CALENDAR_SHOW_DETAILS)
+        resize++;
+
       calendar->display_flags = flags;
       if (resize)
        gtk_widget_queue_resize (GTK_WIDGET (calendar));
index c6a0afbd4a49c28c51eb054ff9ae202013a84caa..5fa887d39bb37e5f971be06990fb91742c46d748 100644 (file)
@@ -51,13 +51,28 @@ typedef struct _GtkCalendarClass       GtkCalendarClass;
 
 typedef struct _GtkCalendarPrivate     GtkCalendarPrivate;
 
+/**
+ * GtkCalendarDisplayOptions:
+ * @GTK_CALENDAR_SHOW_HEADING: Specifies that the month and year should be displayed.
+ * @GTK_CALENDAR_SHOW_DAY_NAMES: Specifies that three letter day descriptions should be present.
+ * @GTK_CALENDAR_NO_MONTH_CHANGE: Prevents the user from switching months with the calendar.
+ * @GTK_CALENDAR_SHOW_WEEK_NUMBERS: Displays each week numbers of the current year, down the
+ * left side of the calendar.
+ * @GTK_CALENDAR_WEEK_START_MONDAY: Since GTK+ 2.4, this option is deprecated and ignored by GTK+.
+ * The information on which day the calendar week starts is derived from the locale.
+ * @GTK_CALENDAR_SHOW_DETAILS: Just show an indicator, not the full details
+ * text when details are provided. See gtk_calendar_set_detail_func().
+ *
+ * These options can be used to influence the display and behaviour of a #GtkCalendar.
+ */
 typedef enum
 {
   GTK_CALENDAR_SHOW_HEADING            = 1 << 0,
   GTK_CALENDAR_SHOW_DAY_NAMES          = 1 << 1,
   GTK_CALENDAR_NO_MONTH_CHANGE         = 1 << 2,
   GTK_CALENDAR_SHOW_WEEK_NUMBERS       = 1 << 3,
-  GTK_CALENDAR_WEEK_START_MONDAY       = 1 << 4
+  GTK_CALENDAR_WEEK_START_MONDAY       = 1 << 4,
+  GTK_CALENDAR_SHOW_DETAILS            = 1 << 5,
 } GtkCalendarDisplayOptions;
 
 /**
index 0c751fbdd0d53e96c8d521a01337b6931ca7859b..d3cf08c83278b2e11bbb325e1f9b27ce017a3f9c 100644 (file)
@@ -30,9 +30,9 @@
 
 typedef struct _CalendarData
 {
-  GtkWidget     *calendar_widget;
-  GtkWidget *flag_checkboxes[5];
-  gboolean  settings[5];
+  GtkWidget *calendar_widget;
+  GtkWidget *flag_checkboxes[6];
+  gboolean  settings[6];
   GtkWidget *font_dialog;
   GtkWidget *window;
   GtkWidget *prev2_sig;
@@ -431,6 +431,7 @@ create_calendar(void)
       { FALSE, "No Month _Change" },
       { TRUE,  "Show _Week Numbers" },
       { FALSE, "Week Start _Monday" },
+      { TRUE,  "Show De_tails" },
     };
 
   calendar_data.window = NULL;
@@ -602,7 +603,7 @@ create_calendar(void)
 
   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
 
-  toggle = gtk_check_button_new_with_mnemonic ("_Show Details");
+  toggle = gtk_check_button_new_with_mnemonic ("_Use Details");
   g_signal_connect (toggle, "toggled",
                     G_CALLBACK(calendar_toggle_details),
                     &calendar_data);
@@ -610,7 +611,7 @@ create_calendar(void)
   
   /* Build the Right frame with the flags in */ 
 
-  vbox = gtk_vbox_new(FALSE, DEF_PAD_SMALL);
+  vbox = gtk_vbox_new(FALSE, 0);
   frame = create_expander ("<b>Flags</b>", vbox, 1, 0);
   gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);