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>
|
2004-05-10 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
|
||||||
|
|
||||||
* src/glade-widget-class.c, glade-widget-class.c: fix the build
|
* 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.
|
* File Selection for selecting icon xpm files.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
static void
|
static void
|
||||||
on_icon_filesel_ok (GtkWidget *widget, GladeMenuEditor *menued)
|
on_icon_button_clicked (GtkWidget *widget, gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget *filesel;
|
GladeMenuEditor *menued;
|
||||||
const gchar *filename;
|
GtkWidget *filechooser;
|
||||||
|
const gchar *filename = NULL;
|
||||||
gint filename_len;
|
gint filename_len;
|
||||||
|
const gchar *icon;
|
||||||
|
|
||||||
filesel = gtk_widget_get_toplevel (widget);
|
menued = GLADE_MENU_EDITOR (gtk_widget_get_toplevel (GTK_WIDGET (widget)));
|
||||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
|
|
||||||
|
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
|
/* If the filename ends in '/' it means the user wants to reset the
|
||||||
pixmap to NULL. */
|
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),
|
set_entry_text (GTK_ENTRY (GTK_COMBO (menued->icon_widget)->entry),
|
||||||
filename);
|
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
|
/* 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
|
static void
|
||||||
gpw_on_open_filesel_ok (GtkWidget *widget, gpointer not_used)
|
gpw_open_cb (void)
|
||||||
{
|
{
|
||||||
GtkWidget *filesel;
|
GladeProjectWindow *gpw;
|
||||||
const gchar *path;
|
GtkWidget *filechooser;
|
||||||
|
const gchar *path = NULL;
|
||||||
|
|
||||||
filesel = gtk_widget_get_toplevel (widget);
|
gpw = glade_project_window_get ();
|
||||||
|
|
||||||
/* Get the filename and destroy the dialog */
|
filechooser = glade_util_file_chooser_new (_("Open..."), GTK_WINDOW (gpw->window),
|
||||||
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
|
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||||
gtk_widget_destroy (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)
|
if (!path)
|
||||||
return;
|
return;
|
||||||
@ -142,39 +147,12 @@ gpw_on_open_filesel_ok (GtkWidget *widget, gpointer not_used)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gpw_open_cb (void)
|
gpw_save (GladeProject *project, const gchar *path)
|
||||||
{
|
{
|
||||||
GladeProjectWindow *gpw;
|
GladeProjectWindow *gpw;
|
||||||
GtkWidget *filesel;
|
|
||||||
|
|
||||||
gpw = glade_project_window_get ();
|
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 ();
|
|
||||||
|
|
||||||
if (!glade_project_save (project, path))
|
if (!glade_project_save (project, path))
|
||||||
{
|
{
|
||||||
GladeProjectWindow *gpw;
|
GladeProjectWindow *gpw;
|
||||||
@ -196,7 +174,8 @@ gpw_save_cb (void)
|
|||||||
{
|
{
|
||||||
GladeProjectWindow *gpw;
|
GladeProjectWindow *gpw;
|
||||||
GladeProject *project;
|
GladeProject *project;
|
||||||
GtkWidget *filesel;
|
GtkWidget *filechooser;
|
||||||
|
const gchar *path = NULL;
|
||||||
|
|
||||||
gpw = glade_project_window_get ();
|
gpw = glade_project_window_get ();
|
||||||
project = gpw->project;
|
project = gpw->project;
|
||||||
@ -219,28 +198,44 @@ gpw_save_cb (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If instead we dont have a path yet, fire up a file selector */
|
/* If instead we dont have a path yet, fire up a file selector */
|
||||||
filesel = glade_util_file_selection_new (_("Save ..."), GTK_WINDOW (gpw->window));
|
filechooser = glade_util_file_chooser_new (_("Save..."), GTK_WINDOW (gpw->window),
|
||||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
"clicked", G_CALLBACK (gpw_on_save_filesel_ok),
|
|
||||||
project);
|
|
||||||
|
|
||||||
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
|
static void
|
||||||
gpw_save_as_cb (void)
|
gpw_save_as_cb (void)
|
||||||
{
|
{
|
||||||
GladeProjectWindow *gpw;
|
GladeProjectWindow *gpw;
|
||||||
GtkWidget *filesel;
|
GladeProject *project;
|
||||||
|
GtkWidget *filechooser;
|
||||||
|
const gchar *path = NULL;
|
||||||
|
|
||||||
gpw = glade_project_window_get ();
|
gpw = glade_project_window_get ();
|
||||||
|
project = gpw->project;
|
||||||
|
|
||||||
filesel = glade_util_file_selection_new (_("Save as ..."), GTK_WINDOW (gpw->window));
|
filechooser = glade_util_file_chooser_new (_("Save as ..."), GTK_WINDOW (gpw->window),
|
||||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
"clicked", G_CALLBACK (gpw_on_save_filesel_ok),
|
|
||||||
gpw->project);
|
|
||||||
|
|
||||||
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
|
static gboolean
|
||||||
@ -248,7 +243,7 @@ gpw_confirm_close_project (GladeProject *project)
|
|||||||
{
|
{
|
||||||
GladeProjectWindow *gpw;
|
GladeProjectWindow *gpw;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
gboolean close;
|
gboolean close = FALSE;
|
||||||
char *msg;
|
char *msg;
|
||||||
gint ret;
|
gint ret;
|
||||||
|
|
||||||
@ -289,17 +284,25 @@ gpw_confirm_close_project (GladeProject *project)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkWidget *filesel;
|
GtkWidget *filechooser;
|
||||||
|
const gchar *path = NULL;
|
||||||
|
|
||||||
filesel = glade_util_file_selection_new (_("Save ..."), GTK_WINDOW (gpw->window));
|
filechooser = glade_util_file_chooser_new (_("Save ..."), GTK_WINDOW (gpw->window),
|
||||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
"clicked", G_CALLBACK (gpw_on_save_filesel_ok),
|
|
||||||
project);
|
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;
|
close = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GTK_RESPONSE_NO:
|
case GTK_RESPONSE_NO:
|
||||||
close = TRUE;
|
close = TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -156,7 +156,7 @@ glade_property_set (GladeProperty *property, const GValue *value)
|
|||||||
|
|
||||||
property->loading = TRUE;
|
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)
|
if (property->class->set_function)
|
||||||
(*property->class->set_function) (G_OBJECT (property->widget->widget), value);
|
(*property->class->set_function) (G_OBJECT (property->widget->widget), value);
|
||||||
else
|
else
|
||||||
|
@ -294,32 +294,24 @@ glade_util_hide_window (GtkWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* glade_util_file_selection_new:
|
* glade_util_file_chooser_new:
|
||||||
* @title: dialog title
|
* @title: dialog title
|
||||||
* @parent: the window the dialog is set transient for
|
* @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
|
* Returns a file chooser dialog. It's up to the caller
|
||||||
* callback for the OK button and then to show the dialog
|
* to show the dialog
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
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;
|
g_assert (action == GTK_FILE_CHOOSER_ACTION_OPEN || action == GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
|
return gtk_file_chooser_dialog_new (title, parent, action,
|
||||||
filesel = gtk_file_selection_new (title);
|
action == GTK_FILE_CHOOSER_ACTION_OPEN ? GTK_STOCK_OPEN : GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
||||||
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION(filesel)->cancel_button),
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
"clicked", G_CALLBACK (gtk_widget_destroy),
|
NULL);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* changes each occurence of the character a on the string str by the character b.
|
* 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
|
* duplicates the string passed as argument, but changing each underscore
|
||||||
* in the original string by two underscores. Returns a newly allocated
|
* in the original string by two underscores. Returns a newly allocated
|
||||||
* string, or NULL if there is not enough memory.
|
* string.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
glade_util_duplicate_underscores (const char *name)
|
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 *underscored_name = g_malloc (strlen (name) * 2 + 1);
|
||||||
char *tmp_underscored = underscored_name;
|
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))
|
for (tmp = last_tmp; *tmp; tmp = g_utf8_next_char (tmp))
|
||||||
{
|
{
|
||||||
if (*tmp == '_')
|
if (*tmp == '_')
|
||||||
|
@ -23,7 +23,7 @@ void glade_util_hide_window (GtkWindow *window);
|
|||||||
gchar *glade_util_gtk_combo_func (gpointer data);
|
gchar *glade_util_gtk_combo_func (gpointer data);
|
||||||
gpointer glade_util_gtk_combo_find (GtkCombo *combo);
|
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);
|
void glade_util_replace (char *str, char a, char b);
|
||||||
char *glade_util_duplicate_underscores (const char *name);
|
char *glade_util_duplicate_underscores (const char *name);
|
||||||
|
|
||||||
|
@ -250,12 +250,15 @@ glade_widget_class_list_signals (GladeWidgetClass *class)
|
|||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
glade_widget_class_create_icon (GladeWidgetClass *class)
|
glade_widget_class_create_icon (GladeWidgetClass *class)
|
||||||
{
|
{
|
||||||
GtkWidget *icon;
|
GtkWidget *icon = NULL;
|
||||||
gchar *icon_path;
|
gchar *icon_path;
|
||||||
|
|
||||||
icon_path = g_strdup_printf (PIXMAPS_DIR "/%s.png", class->generic_name);
|
if (class->generic_name)
|
||||||
icon = gtk_image_new_from_file (icon_path);
|
{
|
||||||
g_free (icon_path);
|
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;
|
return icon;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
<SetFunction>ignore</SetFunction>
|
<SetFunction>ignore</SetFunction>
|
||||||
<GetFunction>ignore</GetFunction>
|
<GetFunction>ignore</GetFunction>
|
||||||
</Property>
|
</Property>
|
||||||
|
<Property Id="type">
|
||||||
|
<SetFunction>ignore</SetFunction>
|
||||||
|
<GetFunction>ignore</GetFunction>
|
||||||
|
</Property>
|
||||||
<Property Id="allow-shrink" Disabled="TRUE" />
|
<Property Id="allow-shrink" Disabled="TRUE" />
|
||||||
<Property Id="allow-grow" Disabled="TRUE" />
|
<Property Id="allow-grow" Disabled="TRUE" />
|
||||||
<Property Id="resize-mode" Disabled="TRUE" />
|
<Property Id="resize-mode" Disabled="TRUE" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user