]> Pileus Git - ~andy/gtk/blobdiff - tests/testcalendar.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testcalendar.c
index 1960c5e0e4271eeeabbbc9abededfaa946339d9f..84de5ec139c15b877250439f7d024687c5c76823 100644 (file)
@@ -3,19 +3,18 @@
  * 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"
@@ -243,18 +242,15 @@ void calendar_select_font (GtkWidget    *button,
                                  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 gchar*
@@ -399,7 +395,8 @@ create_calendar(void)
   GtkWidget *frame, *label, *bbox, *align, *details;
 
   GtkSizeGroup *size;
-  GtkStyle *style;
+  GtkStyleContext *context;
+  PangoFontDescription *font_desc;
   gchar *font;
   gint i;
   
@@ -478,11 +475,12 @@ create_calendar(void)
   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),
@@ -490,7 +488,8 @@ create_calendar(void)
 
   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_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
@@ -510,7 +509,8 @@ create_calendar(void)
 
   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_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
@@ -530,7 +530,8 @@ create_calendar(void)
 
   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_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);