mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-10-16 00:04:58 -04:00
rewrote function to create a GtkFileSelector or GtkFileChooser depending
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.
This commit is contained in:
parent
5476bd6629
commit
ca5f1e2c78
@ -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-11-02 Ivan Wong <email@ivanwong.info>
|
||||
|
||||
* src/Makefile.am: Fix a few glitches that only show up on win32
|
||||
|
@ -36,7 +36,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)
|
||||
|
@ -1764,18 +1764,18 @@ on_icon_button_clicked (GtkWidget *widget, gpointer user_data)
|
||||
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);
|
||||
|
||||
|
@ -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 *project)
|
||||
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);
|
||||
|
||||
|
@ -411,34 +411,75 @@ glade_util_hide_window (GtkWindow *window)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
return file_chooser;
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
||||
|
||||
@ -25,7 +33,10 @@ void glade_util_hide_window (GtkWindow *window);
|
||||
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user