[Glade-devel] Glade 3 targeting gtk 2.4 or gtk 2.6?



--=-q4os2BkMvy7j/5z2NCqV
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

If possible could we please require a lower number and use
GTK_MAJOR_VERSION and GTK_MINOR_VERSION to disable rather than setting a
higher version number??? Especially when it comes to non-critial
features like a most recent list and the file dialog...

Currently, one of my boxes has FC1. The reason glade-3 doesnt compile on
this box is because GtkFileChooser is used or open and save of .glade
file operations and my box has 2.2.x. Attached is patch that lets you
compile - it just reverts to using GtkFileSelector if you dont have 2.4
by using the version macros described above.

What do people think about this approach? Obviously if there is some
nasty bug or core feature that is blocked we would have to cut our
losses and just enforce the higher version number... 

- Shane



On Thu, 2004-10-28 at 06:55, Todd Fisher wrote:
Hi,
    Just curious is glade 3 targeting gtk 2.4 or 2.6 or are there plans 
to provide backwards
compatiblity.  I ask because this could persuade my implementation of 
session management
to either looking into using GKeyFile or following more closely bug 
142176. 

-todd

_______________________________________________
Glade-devel maillist  -  Glade-devel lists ximian com
http://lists.ximian.com/mailman/listinfo/glade-devel

--=-q4os2BkMvy7j/5z2NCqV
Content-Disposition: attachment; filename=glade3-gtkfilesel2.patch
Content-Type: text/x-patch; name=glade3-gtkfilesel2.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: glade3/ChangeLog
===================================================================
RCS file: /cvs/gnome/glade3/ChangeLog,v
retrieving revision 1.313
diff -u -p -r1.313 ChangeLog
--- glade3/ChangeLog    28 Oct 2004 18:35:30 -0000      1.313
+++ glade3/ChangeLog    2 Nov 2004 11:09:28 -0000
@@ -1,3 +1,11 @@
+2004-11-02 Shane Butler <shane_b users sourceforge net>
+
+       * src/glade-utils.[ch] (glade_util_file_dialog_new): rewrote function to create a GtkFileSelector or 
GtkFileChooser depending on the GTK+ version.
+       (glade_util_file_dialog_get_filename, glade_util_file_dialog_set_filename): Metods to retrieve and 
set the filename of whichever file selector type is supported. 
+       * src/glade-project-window.c (gpw_open_cb, gpw_save_cb, gpw_save_as_cb, gpw_confirm_close_project): 
Update to use new functions (above).
+       * src/glade-menu-editor.c (on_icon_button_clicked): Update to new functions.
+       * configure.in: Revert back to requiring GTK+ 2.2 or above.
+
 2004-10-28  Tristan Van Berkom  <tristan van berkom gmail com>
 
        * src/glade-editor.[ch]: Implemented glade_editor_query_popup(), also obsoleted
Index: glade3/configure.in
===================================================================
RCS file: /cvs/gnome/glade3/configure.in,v
retrieving revision 1.31
diff -u -p -r1.31 configure.in
--- glade3/configure.in 25 Oct 2004 17:39:34 -0000      1.31
+++ glade3/configure.in 2 Nov 2004 11:09:28 -0000
@@ -33,7 +33,7 @@ AM_GLIB_GNU_GETTEXT
 dnl ================================================================
 dnl Start of pkg-config checks
 dnl ================================================================
-PKG_CHECK_MODULES(GLADE, gtk+-2.0 >= 2.4.0  libxml-2.0 >= 2.4.0)
+PKG_CHECK_MODULES(GLADE, gtk+-2.0 >= 2.2.0  libxml-2.0 >= 2.4.0)
 GLADE_LIBS="${GLADE_LIBS}"
 AC_SUBST(GLADE_LIBS)
 AC_SUBST(GLADE_CFLAGS)
Index: glade3/src/glade-menu-editor.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-menu-editor.c,v
retrieving revision 1.13
diff -u -p -r1.13 glade-menu-editor.c
--- glade3/src/glade-menu-editor.c      4 Oct 2004 20:18:59 -0000       1.13
+++ glade3/src/glade-menu-editor.c      2 Nov 2004 11:09:38 -0000
@@ -1764,18 +1764,18 @@ on_icon_button_clicked (GtkWidget *widge
        GtkWidget *filechooser;
        const gchar *filename = NULL;
        gint filename_len;
-       const gchar *icon;
+       gchar *icon;
 
        menued = GLADE_MENU_EDITOR (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
 
-       filechooser = glade_util_file_chooser_new (_("Select icon"), GTK_WINDOW (menued),
-                                                  GTK_FILE_CHOOSER_ACTION_OPEN);
+       filechooser = glade_util_file_dialog_new (_("Select icon"), GTK_WINDOW (menued),
+                                                  GLADE_FILE_DIALOG_ACTION_OPEN);
 
        icon = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (menued->icon_widget)->entry));
-       gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), icon);
+       glade_util_file_dialog_set_filename (filechooser, icon);
 
        if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
-               filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
+               filename = glade_util_file_dialog_get_filename (filechooser);
 
        gtk_widget_destroy (filechooser);
 
Index: glade3/src/glade-project-window.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-project-window.c,v
retrieving revision 1.83
diff -u -p -r1.83 glade-project-window.c
--- glade3/src/glade-project-window.c   22 Oct 2004 16:19:39 -0000      1.83
+++ glade3/src/glade-project-window.c   2 Nov 2004 11:09:40 -0000
@@ -132,12 +132,12 @@ gpw_open_cb (void)
 
        gpw = glade_project_window_get ();
 
-       filechooser = glade_util_file_chooser_new (_("Open..."), GTK_WINDOW (gpw->window),
-                                                  GTK_FILE_CHOOSER_ACTION_OPEN);
+       filechooser = glade_util_file_dialog_new (_("Open..."), GTK_WINDOW (gpw->window),
+                                                  GLADE_FILE_DIALOG_ACTION_OPEN);
 
        if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
-               path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
-       
+               path = glade_util_file_dialog_get_filename (filechooser);
+
        gtk_widget_destroy (filechooser);
 
        if (!path)
@@ -198,12 +198,12 @@ gpw_save_cb (void)
        }
 
        /* If instead we dont have a path yet, fire up a file selector */
-       filechooser = glade_util_file_chooser_new (_("Save..."), GTK_WINDOW (gpw->window),
-                                                  GTK_FILE_CHOOSER_ACTION_SAVE);
+       filechooser = glade_util_file_dialog_new (_("Save..."), GTK_WINDOW (gpw->window),
+                                                  GLADE_FILE_DIALOG_ACTION_SAVE);
 
        
        if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
-               path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
+               path = glade_util_file_dialog_get_filename (filechooser);
 
        gtk_widget_destroy (filechooser);
 
@@ -224,11 +224,11 @@ gpw_save_as_cb (void)
        gpw = glade_project_window_get ();
        project = gpw->active_project;
 
-       filechooser = glade_util_file_chooser_new (_("Save as ..."), GTK_WINDOW (gpw->window),
-                                                  GTK_FILE_CHOOSER_ACTION_SAVE);
+       filechooser = glade_util_file_dialog_new (_("Save as ..."), GTK_WINDOW (gpw->window),
+                                                  GLADE_FILE_DIALOG_ACTION_SAVE);
 
        if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
-               path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
+               path = glade_util_file_dialog_get_filename (filechooser);
 
        gtk_widget_destroy (filechooser);
 
@@ -286,11 +286,11 @@ gpw_confirm_close_project (GladeProject 
                        GtkWidget *filechooser;
                        const gchar *path = NULL;
 
-                       filechooser = glade_util_file_chooser_new (_("Save ..."), GTK_WINDOW (gpw->window),
-                                                                  GTK_FILE_CHOOSER_ACTION_SAVE);
+                       filechooser = glade_util_file_dialog_new (_("Save ..."), GTK_WINDOW (gpw->window),
+                                                                  GLADE_FILE_DIALOG_ACTION_SAVE);
 
                        if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
-                               path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
+                               path = glade_util_file_dialog_get_filename (filechooser);
 
                        gtk_widget_destroy (filechooser);
 
Index: glade3/src/glade-utils.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-utils.c,v
retrieving revision 1.33
diff -u -p -r1.33 glade-utils.c
--- glade3/src/glade-utils.c    22 Oct 2004 16:19:39 -0000      1.33
+++ glade3/src/glade-utils.c    2 Nov 2004 11:09:42 -0000
@@ -347,34 +347,75 @@ glade_util_hide_window (GtkWindow *windo
 }
 
 /**
- * glade_util_file_chooser_new:
+ * glade_util_file_dialog_new:
  * @title: dialog title
  * @parent: the parent #GtkWindow for the dialog
- * @action: a #GtkFileChooserAction to say if the dialog will open or save
+ * @action: a #GladeUtilFileDialogType to say if the dialog will open or save
  *
- * Returns: a file chooser dialog. The caller is responsible for showing the
- *          dialog
+ * Returns: a file chooser or file selector dialog. The caller is responsible 
+ *          for showing the dialog
  */
 GtkWidget *
-glade_util_file_chooser_new (const gchar *title, GtkWindow *parent, 
-                            GtkFileChooserAction action)
+glade_util_file_dialog_new (const gchar *title, GtkWindow *parent, 
+                            GladeUtilFileDialogType action)
 {
-       GtkWidget *file_chooser;
+       GtkWidget *file_dialog;
 
-       g_return_val_if_fail ((action == GTK_FILE_CHOOSER_ACTION_OPEN ||
-                              action == GTK_FILE_CHOOSER_ACTION_SAVE), NULL);
+       g_return_val_if_fail ((action == GLADE_FILE_DIALOG_ACTION_OPEN ||
+                              action == GLADE_FILE_DIALOG_ACTION_SAVE), NULL);
 
-       file_chooser = gtk_file_chooser_dialog_new (title, parent, action,
+#if GTK_MAJOR_VERSION >= 2
+#if GTK_MINOR_VERSION >= 4
+       file_dialog = gtk_file_chooser_dialog_new (title, parent, action,
                                                    GTK_STOCK_CANCEL,
                                                    GTK_RESPONSE_CANCEL,
-                                                   action == GTK_FILE_CHOOSER_ACTION_OPEN ?
+                                                   action == GLADE_FILE_DIALOG_ACTION_OPEN ?
                                                    GTK_STOCK_OPEN : GTK_STOCK_SAVE,
                                                    GTK_RESPONSE_OK,
                                                    NULL);
+#else
+       file_dialog = gtk_file_selection_new (title);
+#endif
+#endif
+       gtk_window_set_position (GTK_WINDOW (file_dialog), GTK_WIN_POS_CENTER);
 
-       gtk_window_set_position (GTK_WINDOW (file_chooser), GTK_WIN_POS_CENTER);
+       return file_dialog;
+}
+
+/**
+ * glade_util_file_dialog_get_filename:
+ * @file_dialog: a #GtkWidget that is either a #GtkFileSelector or #GtkFileChooser
+ *
+ * Returns: The filename selected by the user.
+ */
+gchar *
+glade_util_file_dialog_get_filename (GtkWidget *file_dialog)
+{
+#if GTK_MAJOR_VERSION >= 2
+#if GTK_MINOR_VERSION >= 4
+       return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog));
+#else
+       return gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_dialog));
+#endif
+#endif
+}
 
-       return file_chooser;
+/**
+ * glade_util_file_dialog_set_filename:
+ * @file_dialog: a #GtkWidget that is either a #GtkFileSelector or #GtkFileChooser
+ * @filename: the filename to be set.
+ *
+ */
+void
+glade_util_file_dialog_set_filename (GtkWidget *file_dialog, gchar *filename)
+{
+#if GTK_MAJOR_VERSION >= 2
+#if GTK_MINOR_VERSION >= 4
+       gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_dialog), filename);
+#else
+       gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_dialog), filename);
+#endif
+#endif
 }
 
 /**
Index: glade3/src/glade-utils.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-utils.h,v
retrieving revision 1.23
diff -u -p -r1.23 glade-utils.h
--- glade3/src/glade-utils.h    16 May 2004 19:40:04 -0000      1.23
+++ glade3/src/glade-utils.h    2 Nov 2004 11:09:42 -0000
@@ -5,6 +5,14 @@
 G_BEGIN_DECLS
 
 
+typedef enum   _GladeUtilFileDialogType GladeUtilFileDialogType;
+
+enum _GladeUtilFileDialogType
+{
+        GLADE_FILE_DIALOG_ACTION_OPEN,
+        GLADE_FILE_DIALOG_ACTION_SAVE
+};
+
 #define glade_implement_me() g_print ("Implement me : %s %d %s\n", __FILE__, __LINE__, G_GNUC_FUNCTION);
 
 
@@ -23,7 +31,10 @@ void         glade_util_hide_window          (GtkWindow
 gchar          *glade_util_gtk_combo_func      (gpointer data);
 gpointer       glade_util_gtk_combo_find       (GtkCombo *combo);
 
-GtkWidget       *glade_util_file_chooser_new (const gchar *title, GtkWindow *parent, GtkFileChooserAction 
action);
+GtkWidget       *glade_util_file_dialog_new (const gchar *title, GtkWindow *parent, GladeUtilFileDialogType 
action);
+gchar           *glade_util_file_dialog_get_filename (GtkWidget *file_dialog);
+void             glade_util_file_dialog_set_filename (GtkWidget *file_dialog, gchar *filename);
+
 void           glade_util_replace (char *str, char a, char b);
 char           *glade_util_duplicate_underscores (const char *name);
 

--=-q4os2BkMvy7j/5z2NCqV--





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]