mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-10-08 00:04:35 -04:00
Use the new save/open dialog box in gtk+-2.4. Patch by kov at debian dot
2004-05-16 Joaquin Cuenca Abela <e98cuenc@yahoo.com> * src/glade-menu-editor.c, glade-project-window.c, glade-utils.[ch]: Use the new save/open dialog box in gtk+-2.4. Patch by kov at debian dot org, slightly modified by me. * src/glade-widget-class.c: prevent a crash when loading a widget without a generic_name. The crash only happens with gtk+-2.4 * src/gtkwindow.xml: ignore the setting and getting of the "type" property on GtkWindows, as it's construct only.
This commit is contained in:
parent
43c9d51dac
commit
10cb84fb85
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2004-05-16 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
|
||||
|
||||
* src/glade-menu-editor.c, glade-project-window.c, glade-utils.[ch]:
|
||||
Use the new save/open dialog box in gtk+-2.4. Patch by kov at
|
||||
debian dot org, slightly modified by me.
|
||||
|
||||
* src/glade-widget-class.c: prevent a crash when loading a widget
|
||||
without a generic_name. The crash only happens with gtk+-2.4
|
||||
|
||||
* src/gtkwindow.xml: ignore the setting and getting of the "type"
|
||||
property on GtkWindows, as it's construct only.
|
||||
|
||||
2004-05-10 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
|
||||
|
||||
* src/glade-widget-class.c, glade-widget-class.c: fix the build
|
||||
|
@ -1749,14 +1749,29 @@ on_key_press (GtkWidget * widget,
|
||||
* File Selection for selecting icon xpm files.
|
||||
**************************************************************************/
|
||||
static void
|
||||
on_icon_filesel_ok (GtkWidget *widget, GladeMenuEditor *menued)
|
||||
on_icon_button_clicked (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
GtkWidget *filesel;
|
||||
const gchar *filename;
|
||||
GladeMenuEditor *menued;
|
||||
GtkWidget *filechooser;
|
||||
const gchar *filename = NULL;
|
||||
gint filename_len;
|
||||
const gchar *icon;
|
||||
|
||||
filesel = gtk_widget_get_toplevel (widget);
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
|
||||
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);
|
||||
|
||||
icon = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (menued->icon_widget)->entry));
|
||||
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), icon);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
|
||||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
|
||||
|
||||
gtk_widget_destroy (filechooser);
|
||||
|
||||
if (!filename)
|
||||
return;
|
||||
|
||||
/* If the filename ends in '/' it means the user wants to reset the
|
||||
pixmap to NULL. */
|
||||
@ -1766,28 +1781,6 @@ on_icon_filesel_ok (GtkWidget *widget, GladeMenuEditor *menued)
|
||||
|
||||
set_entry_text (GTK_ENTRY (GTK_COMBO (menued->icon_widget)->entry),
|
||||
filename);
|
||||
|
||||
gtk_widget_destroy (filesel);
|
||||
}
|
||||
|
||||
static void
|
||||
on_icon_button_clicked (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
GladeMenuEditor *menued;
|
||||
GtkWidget *filesel;
|
||||
const gchar *icon;
|
||||
|
||||
menued = GLADE_MENU_EDITOR (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
|
||||
|
||||
filesel = glade_util_file_selection_new (_("Select icon"), GTK_WINDOW (menued));
|
||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
||||
"clicked", G_CALLBACK (on_icon_filesel_ok),
|
||||
menued);
|
||||
|
||||
icon = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (menued->icon_widget)->entry));
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), icon);
|
||||
|
||||
gtk_widget_show (filesel);
|
||||
}
|
||||
|
||||
/* This checks if the given icon string is a stock icon name, and if it is
|
||||
|
@ -124,16 +124,21 @@ gpw_new_cb (void)
|
||||
}
|
||||
|
||||
static void
|
||||
gpw_on_open_filesel_ok (GtkWidget *widget, gpointer not_used)
|
||||
gpw_open_cb (void)
|
||||
{
|
||||
GtkWidget *filesel;
|
||||
const gchar *path;
|
||||
GladeProjectWindow *gpw;
|
||||
GtkWidget *filechooser;
|
||||
const gchar *path = NULL;
|
||||
|
||||
filesel = gtk_widget_get_toplevel (widget);
|
||||
gpw = glade_project_window_get ();
|
||||
|
||||
/* Get the filename and destroy the dialog */
|
||||
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
|
||||
gtk_widget_destroy (filesel);
|
||||
filechooser = glade_util_file_chooser_new (_("Open..."), GTK_WINDOW (gpw->window),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
|
||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
|
||||
|
||||
gtk_widget_destroy (filechooser);
|
||||
|
||||
if (!path)
|
||||
return;
|
||||
@ -142,36 +147,9 @@ gpw_on_open_filesel_ok (GtkWidget *widget, gpointer not_used)
|
||||
}
|
||||
|
||||
static void
|
||||
gpw_open_cb (void)
|
||||
gpw_save (GladeProject *project, const gchar *path)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GtkWidget *filesel;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
|
||||
filesel = glade_util_file_selection_new (_("Open ..."), GTK_WINDOW (gpw->window));
|
||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
||||
"clicked", G_CALLBACK (gpw_on_open_filesel_ok),
|
||||
NULL);
|
||||
|
||||
gtk_widget_show (filesel);
|
||||
}
|
||||
|
||||
static void
|
||||
gpw_on_save_filesel_ok (GtkWidget *widget, GladeProject *project)
|
||||
{
|
||||
GtkWidget *filesel;
|
||||
const gchar *path;
|
||||
GladeProjectWindow *gpw;
|
||||
|
||||
filesel = gtk_widget_get_toplevel (widget);
|
||||
|
||||
/* Get the filename and hide the dialog */
|
||||
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
|
||||
gtk_widget_destroy (filesel);
|
||||
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
|
||||
@ -196,7 +174,8 @@ gpw_save_cb (void)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GladeProject *project;
|
||||
GtkWidget *filesel;
|
||||
GtkWidget *filechooser;
|
||||
const gchar *path = NULL;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
project = gpw->project;
|
||||
@ -219,28 +198,44 @@ gpw_save_cb (void)
|
||||
}
|
||||
|
||||
/* If instead we dont have a path yet, fire up a file selector */
|
||||
filesel = glade_util_file_selection_new (_("Save ..."), GTK_WINDOW (gpw->window));
|
||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
||||
"clicked", G_CALLBACK (gpw_on_save_filesel_ok),
|
||||
project);
|
||||
filechooser = glade_util_file_chooser_new (_("Save..."), GTK_WINDOW (gpw->window),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
gtk_widget_show (filesel);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
|
||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
|
||||
|
||||
gtk_widget_destroy (filechooser);
|
||||
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
gpw_save (project, path);
|
||||
}
|
||||
|
||||
static void
|
||||
gpw_save_as_cb (void)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GtkWidget *filesel;
|
||||
GladeProject *project;
|
||||
GtkWidget *filechooser;
|
||||
const gchar *path = NULL;
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
project = gpw->project;
|
||||
|
||||
filesel = glade_util_file_selection_new (_("Save as ..."), GTK_WINDOW (gpw->window));
|
||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
||||
"clicked", G_CALLBACK (gpw_on_save_filesel_ok),
|
||||
gpw->project);
|
||||
filechooser = glade_util_file_chooser_new (_("Save as ..."), GTK_WINDOW (gpw->window),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
gtk_widget_show (filesel);
|
||||
if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
|
||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
|
||||
|
||||
gtk_widget_destroy (filechooser);
|
||||
|
||||
if (!path)
|
||||
return;
|
||||
|
||||
gpw_save (project, path);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -248,7 +243,7 @@ gpw_confirm_close_project (GladeProject *project)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GtkWidget *dialog;
|
||||
gboolean close;
|
||||
gboolean close = FALSE;
|
||||
char *msg;
|
||||
gint ret;
|
||||
|
||||
@ -289,14 +284,22 @@ gpw_confirm_close_project (GladeProject *project)
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *filesel;
|
||||
GtkWidget *filechooser;
|
||||
const gchar *path = NULL;
|
||||
|
||||
filesel = glade_util_file_selection_new (_("Save ..."), GTK_WINDOW (gpw->window));
|
||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
||||
"clicked", G_CALLBACK (gpw_on_save_filesel_ok),
|
||||
project);
|
||||
filechooser = glade_util_file_chooser_new (_("Save ..."), GTK_WINDOW (gpw->window),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
|
||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
|
||||
|
||||
gtk_widget_destroy (filechooser);
|
||||
|
||||
if (!path)
|
||||
break;
|
||||
|
||||
gpw_save (project, path);
|
||||
|
||||
gtk_widget_show (filesel);
|
||||
close = FALSE;
|
||||
}
|
||||
break;
|
||||
|
@ -156,7 +156,7 @@ glade_property_set (GladeProperty *property, const GValue *value)
|
||||
|
||||
property->loading = TRUE;
|
||||
|
||||
/* if there is a custom set_property use it*/
|
||||
/* if there is a custom set_property use it */
|
||||
if (property->class->set_function)
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget), value);
|
||||
else
|
||||
|
@ -294,33 +294,25 @@ glade_util_hide_window (GtkWindow *window)
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_util_file_selection_new:
|
||||
* glade_util_file_chooser_new:
|
||||
* @title: dialog title
|
||||
* @parent: the window the dialog is set transient for
|
||||
* @action: a #GtkFileChooserAction to say if the dialog will open or save
|
||||
*
|
||||
* Returns a file selection dialog. It's up to the caller to set up a
|
||||
* callback for the OK button and then to show the dialog
|
||||
* Returns a file chooser dialog. It's up to the caller
|
||||
* to show the dialog
|
||||
**/
|
||||
GtkWidget *
|
||||
glade_util_file_selection_new (const gchar *title, GtkWindow *parent)
|
||||
glade_util_file_chooser_new (const gchar *title, GtkWindow *parent,
|
||||
GtkFileChooserAction action)
|
||||
{
|
||||
GtkWidget *filesel;
|
||||
|
||||
filesel = gtk_file_selection_new (title);
|
||||
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION(filesel)->cancel_button),
|
||||
"clicked", G_CALLBACK (gtk_widget_destroy),
|
||||
filesel);
|
||||
g_signal_connect_swapped (G_OBJECT (filesel), "delete_event",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
filesel);
|
||||
|
||||
if (GTK_IS_WINDOW (parent))
|
||||
gtk_window_set_transient_for (GTK_WINDOW (filesel), GTK_WINDOW (parent));
|
||||
|
||||
return filesel;
|
||||
g_assert (action == GTK_FILE_CHOOSER_ACTION_OPEN || action == GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
return gtk_file_chooser_dialog_new (title, parent, action,
|
||||
action == GTK_FILE_CHOOSER_ACTION_OPEN ? GTK_STOCK_OPEN : GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* changes each occurence of the character a on the string str by the character b.
|
||||
*/
|
||||
@ -340,7 +332,7 @@ glade_util_replace (char *str, char a, char b)
|
||||
/**
|
||||
* duplicates the string passed as argument, but changing each underscore
|
||||
* in the original string by two underscores. Returns a newly allocated
|
||||
* string, or NULL if there is not enough memory.
|
||||
* string.
|
||||
*/
|
||||
char *
|
||||
glade_util_duplicate_underscores (const char *name)
|
||||
@ -350,12 +342,6 @@ glade_util_duplicate_underscores (const char *name)
|
||||
char *underscored_name = g_malloc (strlen (name) * 2 + 1);
|
||||
char *tmp_underscored = underscored_name;
|
||||
|
||||
if (!underscored_name)
|
||||
{
|
||||
g_critical ("Not enough memory!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (tmp = last_tmp; *tmp; tmp = g_utf8_next_char (tmp))
|
||||
{
|
||||
if (*tmp == '_')
|
||||
|
@ -23,7 +23,7 @@ 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_selection_new (const gchar *title, GtkWindow *parent);
|
||||
GtkWidget *glade_util_file_chooser_new (const gchar *title, GtkWindow *parent, GtkFileChooserAction action);
|
||||
void glade_util_replace (char *str, char a, char b);
|
||||
char *glade_util_duplicate_underscores (const char *name);
|
||||
|
||||
|
@ -250,12 +250,15 @@ glade_widget_class_list_signals (GladeWidgetClass *class)
|
||||
static GtkWidget *
|
||||
glade_widget_class_create_icon (GladeWidgetClass *class)
|
||||
{
|
||||
GtkWidget *icon;
|
||||
GtkWidget *icon = NULL;
|
||||
gchar *icon_path;
|
||||
|
||||
if (class->generic_name)
|
||||
{
|
||||
icon_path = g_strdup_printf (PIXMAPS_DIR "/%s.png", class->generic_name);
|
||||
icon = gtk_image_new_from_file (icon_path);
|
||||
g_free (icon_path);
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
@ -13,6 +13,10 @@
|
||||
<SetFunction>ignore</SetFunction>
|
||||
<GetFunction>ignore</GetFunction>
|
||||
</Property>
|
||||
<Property Id="type">
|
||||
<SetFunction>ignore</SetFunction>
|
||||
<GetFunction>ignore</GetFunction>
|
||||
</Property>
|
||||
<Property Id="allow-shrink" Disabled="TRUE" />
|
||||
<Property Id="allow-grow" Disabled="TRUE" />
|
||||
<Property Id="resize-mode" Disabled="TRUE" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user