Changes to compile with gtk3.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 29 Jan 2014 07:44:40 +0000 (08:44 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 29 Jan 2014 07:44:40 +0000 (08:44 +0100)
configure.ac
libgtkmaskedentry.pc.in
src/gtkcellrenderermasked.c
src/gtkmaskedentry.c
tests/masked_entry.c

index 311fac7085581ecd9b82da5fa47b19d634a0c3a6..67c77edc58ed6c4eb3bcfc54c09bfb4e594c7176 100644 (file)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT([GtkMaskedEntry], [0.0.3], [azagli@libero.it])
+AC_INIT([GtkMaskedEntry], [0.0.4], [azagli@libero.it])
 AC_CONFIG_SRCDIR([src/gtkmaskedentry.c])
 AM_CONFIG_HEADER(config.h)
 
@@ -28,9 +28,9 @@ AC_C_CONST
 
 GTK_DOC_CHECK(1.0)
 
-PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0)
-PKG_CHECK_EXISTS(gladeui-1.0 >= 3.2.0, [GLADEUI_FOUND=yes], [GLADEUI_FOUND=no])
-PKG_CHECK_EXISTS(libgtkform >= 0.2.0, [LIBGTKFORM_FOUND=yes], [LIBGTKFORM_FOUND=no])
+PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0.0)
+PKG_CHECK_EXISTS(gladeui-2.0 >= 3.10.0, [GLADEUI_FOUND=yes], [GLADEUI_FOUND=no])
+PKG_CHECK_EXISTS(libgtkform >= 0.5.0, [LIBGTKFORM_FOUND=yes], [LIBGTKFORM_FOUND=no])
 
 AC_SUBST(GTK_CFLAGS)
 AC_SUBST(GTK_LIBS)
@@ -39,7 +39,7 @@ AM_CONDITIONAL(GLADEUI_FOUND, test $GLADEUI_FOUND = yes)
 AM_CONDITIONAL(LIBGTKFORM_FOUND, test $LIBGTKFORM_FOUND = yes)
 
 if test $LIBGTKFORM_FOUND = yes; then
-PKG_CHECK_MODULES(GTKFORM, libgtkform >= 0.2.0)
+PKG_CHECK_MODULES(GTKFORM, libgtkform >= 0.5.0)
 
 AC_SUBST(GTKFORM_CFLAGS)
 AC_SUBST(GTKFORM_LIBS)
index 5cde12d6cd686311bf3ee1cddf5b84ad041f3ead..d5e842565a81e5335f0217fd4d33f19c92ef50e7 100644 (file)
@@ -4,8 +4,8 @@ libdir=@libdir@
 includedir=@includedir@
 
 Name: @PACKAGE_NAME@
-Description: GTK+ 2.0 Masked Entry Widget
+Description: GTK+ 3.0 Masked Entry Widget
 Version: @PACKAGE_VERSION@
-Requires: gtk+-2.0
+Requires: gtk+-3.0
 Libs: -L${libdir} -lgtkmaskedentry
 Cflags: -I${includedir}
index ccbf1eeededd60aa262b1b823abc9c5176598a53..06f1843d2df881472e2ddb2bb8724c00e4bb4dc9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * GtkCellRendererMasked widget for GTK+
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -43,8 +43,8 @@ static GtkCellEditable *gtk_cell_renderer_masked_start_editing (GtkCellRenderer
                                                                 GdkEvent *event,
                                                                 GtkWidget *widget,
                                                                 const gchar *path,
-                                                                GdkRectangle *background_area,
-                                                                GdkRectangle *cell_area,
+                                                                const GdkRectangle *background_area,
+                                                                const GdkRectangle *cell_area,
                                                                 GtkCellRendererState flags);
 
 
@@ -175,13 +175,17 @@ gtk_cell_renderer_masked_editing_done (GtkCellEditable *entry,
                                        gpointer data)
 {
        const gchar *path, *new_text;
+
+       gboolean editing_canceled;
+
        GtkCellRendererMaskedPrivate *priv = GTK_CELL_RENDERER_MASKED_GET_PRIVATE (data);
 
        priv->entry = NULL;
 
+       g_object_get (G_OBJECT (entry), "editing-canceled", &editing_canceled, NULL);
        gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (data),
-                                       GTK_ENTRY (entry)->editing_canceled);
-       if (GTK_ENTRY (entry)->editing_canceled)
+                                       editing_canceled);
+       if (editing_canceled)
                return;
 
        path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH);
@@ -195,30 +199,38 @@ static GtkCellEditable
                                          GdkEvent *event,
                                          GtkWidget *widget,
                                          const gchar *path,
-                                         GdkRectangle *background_area,
-                                         GdkRectangle *cell_area,
+                                         const GdkRectangle *background_area,
+                                         const GdkRectangle *cell_area,
                                          GtkCellRendererState flags)
 {
        GtkCellRendererMasked *celltext;
        GtkCellRendererMaskedPrivate *priv;
 
+       gboolean editable;
+       gfloat xalign;
+       gchar *text;
+
        celltext = GTK_CELL_RENDERER_MASKED (cell);
        priv = GTK_CELL_RENDERER_MASKED_GET_PRIVATE (cell);
 
        /* If the cell isn't editable we return NULL. */
-       if (GTK_CELL_RENDERER_TEXT (celltext)->editable == FALSE)
+       g_object_get (G_OBJECT (celltext), "editable", &editable, NULL);
+       if (editable == FALSE)
                return NULL;
 
+       g_object_get (G_OBJECT (cell), "xalign", &xalign, NULL);
        priv->entry = g_object_new (GTK_TYPE_MASKED_ENTRY,
                                    "has-frame", FALSE,
-                                   "xalign", cell->xalign,
+                                   "xalign", xalign,
                                    NULL);
 
        if (priv->mask)
                gtk_masked_entry_set_mask (GTK_MASKED_ENTRY (priv->entry), priv->mask);
 
-       if (GTK_CELL_RENDERER_TEXT (celltext)->text)
-               gtk_entry_set_text (GTK_ENTRY (priv->entry), GTK_CELL_RENDERER_TEXT (celltext)->text);
+       text = NULL;
+       g_object_get (G_OBJECT (celltext), "text", &text, NULL);
+       if (text)
+               gtk_entry_set_text (GTK_ENTRY (priv->entry), text);
 
        g_object_set_data_full (G_OBJECT (priv->entry), GTK_CELL_RENDERER_TEXT_PATH, g_strdup (path), g_free);
 
index 81662b5c7f7679d162e34761beb3a792ff3a6c22..4de3e11a8cc69106c88540697f37cf1a6c4c6c11 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * GtkMaskedEntry widget for GTK+
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -262,7 +262,7 @@ gtk_masked_entry_key_press_event (GtkWidget   *widget,
        GtkMaskedEntry *masked_entry = GTK_MASKED_ENTRY (user_data);
        GtkMaskedEntryPrivate *priv = GTK_MASKED_ENTRY_GET_PRIVATE (masked_entry);
 
-       if ((event->keyval == GDK_Tab || event->keyval == GDK_ISO_Left_Tab)
+       if ((event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab)
                && priv->tab_inside)
                {
                        gint pos;
index 9462dd72e250099a31086cbc9abc37ca7d012009..bd3d7f132858eb05514d7f70c155b652ff265662 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * GtkMaskedEntry widget test
- * Copyright (C) 2005-2009 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
  *
  * This software is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -53,8 +53,8 @@ static void
 btn_setmask_on_clicked (GtkButton *button,
                         gpointer user_data)
 {
-       gtk_masked_entry_set_mask (GTK_MASKED_ENTRY (masked_entry), gtk_combo_box_get_active_text (GTK_COMBO_BOX (txtMask)));
-       g_object_set (G_OBJECT (rend), "mask", gtk_combo_box_get_active_text (GTK_COMBO_BOX (txtMask)), NULL);
+       gtk_masked_entry_set_mask (GTK_MASKED_ENTRY (masked_entry), gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (txtMask)));
+       g_object_set (G_OBJECT (rend), "mask", gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (txtMask)), NULL);
 }
 
 static void
@@ -127,18 +127,18 @@ main (int argc, char **argv)
        gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, 0, 0, 3, 3);
        gtk_widget_show (label);
        
-       txtMask = gtk_combo_box_entry_new_text ();
+       txtMask = gtk_combo_box_text_new_with_entry ();
        gtk_table_attach (GTK_TABLE (table), txtMask, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 3, 3);
        gtk_widget_show (txtMask);
        
        /* some mask examples */
-       gtk_combo_box_append_text (GTK_COMBO_BOX (txtMask), "00/00/0000");
-       gtk_combo_box_append_text (GTK_COMBO_BOX (txtMask), "999 999 999"); /* digit excluded 0 */
-       gtk_combo_box_append_text (GTK_COMBO_BOX (txtMask), "@@@ @@@ @@@"); /* alpha */
-       gtk_combo_box_append_text (GTK_COMBO_BOX (txtMask), "^^^ ^^^ ^^^"); /* alpha to upper case */
-       gtk_combo_box_append_text (GTK_COMBO_BOX (txtMask), "ABC 00@@@00");
-       gtk_combo_box_append_text (GTK_COMBO_BOX (txtMask), "### some text");
-       
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (txtMask), "00/00/0000");
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (txtMask), "999 999 999"); /* digit excluded 0 */
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (txtMask), "@@@ @@@ @@@"); /* alpha */
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (txtMask), "^^^ ^^^ ^^^"); /* alpha to upper case */
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (txtMask), "ABC 00@@@00");
+       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (txtMask), "### some text");
+
        btnSetMask = gtk_button_new_with_label ("Set Mask");
        gtk_table_attach (GTK_TABLE (table), btnSetMask, 2, 3, 0, 1, 0, 0, 3, 3);
        gtk_widget_show (btnSetMask);