* Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Grönlund
* Copyright (C) 2000 Tony Gale
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
GHashTable *details_table;
GtkTextBuffer *details_buffer;
- guint details_changed;
+ gulong details_changed;
} CalendarData;
enum
calendar_update_details (CalendarData *data)
{
guint year, month, day;
- const gchar *detail;
+ gchar *detail;
gtk_calendar_get_date (GTK_CALENDAR (data->calendar_widget), &year, &month, &day);
detail = calendar_get_detail (data, year, month, day);
g_signal_handler_block (data->details_buffer, data->details_changed);
gtk_text_buffer_set_text (data->details_buffer, detail ? detail : "", -1);
g_signal_handler_unblock (data->details_buffer, data->details_changed);
+
+ g_free (detail);
}
static void
calendar_date_to_string (data, buffer+27, 256-27);
calendar_set_signal_strings (buffer, data);
-
gtk_calendar_get_date (GTK_CALENDAR (data->window),
- NULL, NULL, &day);
+ NULL, NULL, &day);
- if (GTK_CALENDAR (data->window)->marked_date[day-1] == 0) {
- gtk_calendar_mark_day (GTK_CALENDAR (data->window), day);
- } else {
+ if (gtk_calendar_get_day_is_marked (GTK_CALENDAR (data->window), day))
gtk_calendar_unmark_day (GTK_CALENDAR (data->window), day);
- }
+ else
+ gtk_calendar_mark_day (GTK_CALENDAR (data->window), day);
}
static void
CalendarData *calendar)
{
const char *font = NULL;
- GtkRcStyle *style;
+ PangoFontDescription *font_desc;
if (calendar->window)
- font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
-
- if (font)
- {
- style = gtk_rc_style_new ();
- pango_font_description_free (style->font_desc);
- style->font_desc = pango_font_description_from_string (font);
- gtk_widget_modify_style (calendar->window, style);
- }
+ {
+ font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
+ font_desc = pango_font_description_from_string (font);
+ gtk_widget_override_font (calendar->window, font_desc);
+ pango_font_description_free (font_desc);
+ }
}
-static G_CONST_RETURN gchar*
+static gchar*
calendar_detail_cb (GtkCalendar *calendar,
guint year,
guint month,
{
static char *rainbow[] = { "#900", "#980", "#390", "#095", "#059", "#309", "#908" };
GtkCalendar *calendar = GTK_CALENDAR (data->calendar_widget);
- gint row, col;
-
- for (row = 0; row < 6; ++row)
- for (col = 0; col < 7; ++col)
- {
- gint year, month, day;
- gchar *detail;
-
- year = calendar->year;
- month = calendar->month;
- month += calendar->day_month[row][col];
- day = calendar->day[row][col];
-
- if (month < 1)
- {
- month += 12;
- year -= 1;
- }
- else if (month > 12)
- {
- month -= 12;
- year += 1;
- }
-
- detail = g_strdup_printf ("<span color='%s'>yadda\n"
- "(%04d-%02d-%02d)</span>",
- rainbow[(day - 1) % 7],
- year, month, day);
-
- calendar_set_detail (data, year, month - 1, day, detail);
- }
+ guint year, month, day;
+ gchar *detail;
+
+ gtk_calendar_get_date (calendar,
+ &year, &month, &day);
+
+ for (day = 0; day < 29; ++day)
+ {
+ detail = g_strdup_printf ("<span color='%s'>yadda\n"
+ "(%04d-%02d-%02d)</span>",
+ rainbow[(day - 1) % 7], year, month, day);
+ calendar_set_detail (data, year, month, day, detail);
+ }
gtk_widget_queue_resize (data->calendar_widget);
calendar_update_details (data);
GtkWidget *frame, *label, *bbox, *align, *details;
GtkSizeGroup *size;
- GtkStyle *style;
+ GtkStyleContext *context;
+ PangoFontDescription *font_desc;
gchar *font;
gint i;
G_CALLBACK (gtk_false),
NULL);
- hpaned = gtk_hpaned_new ();
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
/* Calendar widget */
G_CALLBACK (calendar_next_year),
&calendar_data);
- rpane = gtk_vbox_new (FALSE, DEF_PAD_SMALL);
+ rpane = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
gtk_paned_pack2 (GTK_PANED (hpaned), rpane, FALSE, FALSE);
/* Build the right font-button */
- vbox = gtk_vbox_new(FALSE, DEF_PAD_SMALL);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
frame = create_frame ("<b>Options</b>", vbox, 1, 0);
gtk_box_pack_start (GTK_BOX (rpane), frame, FALSE, TRUE, 0);
size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- gtk_widget_ensure_style (calendar);
- style = gtk_widget_get_style (calendar);
- font = pango_font_description_to_string (style->font_desc);
+ context = gtk_widget_get_style_context (calendar);
+ gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL, &font_desc, NULL);
+ font = pango_font_description_to_string (font_desc);
button = gtk_font_button_new_with_font (font);
g_free (font);
+ pango_font_description_free (font_desc);
g_signal_connect (button, "font-set",
G_CALLBACK(calendar_select_font),
label = gtk_label_new_with_mnemonic ("_Font:");
gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_size_group_add_widget (size, label);
- hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
label = gtk_label_new_with_mnemonic ("Details W_idth:");
gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_size_group_add_widget (size, label);
- hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
label = gtk_label_new_with_mnemonic ("Details H_eight:");
gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_size_group_add_widget (size, label);
- hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
/* Build the right details frame */
- vbox = gtk_vbox_new(FALSE, DEF_PAD_SMALL);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
frame = create_frame ("<b>Details</b>", vbox, 1, 1);
gtk_box_pack_start (GTK_BOX (rpane), frame, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), scroller, FALSE, TRUE, 0);
- hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), hbox);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, TRUE, 0);
/* Build the Right frame with the flags in */
- vbox = gtk_vbox_new(FALSE, 0);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
frame = create_expander ("<b>Flags</b>", vbox, 1, 0);
gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);
* Build the Signal-event part.
*/
- vbox = gtk_vbox_new (TRUE, DEF_PAD_SMALL);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
+ gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
frame = create_frame ("<b>Signal Events</b>", vbox, 1, 0);
- hbox = gtk_hbox_new (FALSE, 3);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
label = gtk_label_new ("Signal:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
calendar_data.last_sig = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), calendar_data.last_sig, FALSE, TRUE, 0);
- hbox = gtk_hbox_new (FALSE, 3);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
label = gtk_label_new ("Previous signal:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
calendar_data.prev_sig = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev_sig, FALSE, TRUE, 0);
- hbox = gtk_hbox_new (FALSE, 3);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
label = gtk_label_new ("Second previous signal:");
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
* Glue everything together
*/
- bbox = gtk_hbutton_box_new ();
+ bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
button = gtk_button_new_with_label ("Close");
g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
gtk_container_add (GTK_CONTAINER (bbox), button);
- vbox = gtk_vbox_new (FALSE, DEF_PAD_SMALL);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
- gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), hpaned,
+ TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL),
+ FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), frame,
+ FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL),
+ FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), bbox,
+ FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
{
gtk_init (&argc, &argv);
+ if (g_getenv ("GTK_RTL"))
+ gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+
create_calendar();
gtk_main();