Commit fb79368d authored by Tristan Van Berkom's avatar Tristan Van Berkom

Reverted the project format menu from edit


	* src/glade-window.c: Reverted the project format menu from edit

	* src/glade-utils.c: Add file format option to "save as" dialog,
	also added new filters for .ui files.


svn path=/trunk/; revision=1777
parent 636521d7
2008-04-08 Tristan Van Berkom <tvb@gnome.org>
* src/glade-window.c: Reverted the project format menu from edit
* src/glade-utils.c: Add file format option to "save as" dialog,
also added new filters for .ui files.
2008-04-07 Tristan Van Berkom <tvb@gnome.org>
* autogen.sh: Run gtkdocize with --flavour=no-tmpl
......@@ -18,7 +25,6 @@
gladeui/glade-project.c: Added some description statements to newly
documented files, fixed some warnings in other sources.
2008-04-06 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/glade-gtk.c: Implemented dual format for atk
......
......@@ -35,8 +35,8 @@
<para>
This document attempts to describe how to use the Glade UI Designer core
library to integrate Glade into your application and how to integrate your
custom GTK+ derived widgets into the Glade UI Builder.
</para>
custom GTK+ derived widgets into the Glade UI Designer.
</para>
<para>You can always get the latest version of this document <ulink url="http://glade.gnome.org/docs/index.html">here</ulink>
and you should have received a copy with the glade-3 tarball.</para>
......
......@@ -484,18 +484,85 @@ glade_util_hide_window (GtkWindow *window)
gtk_window_move(window, x, y);
}
static void
format_libglade_button_clicked (GtkWidget *widget,
GladeProject *project)
{
glade_project_set_format (project, GLADE_PROJECT_FORMAT_LIBGLADE);
}
static void
format_builder_button_clicked (GtkWidget *widget,
GladeProject *project)
{
glade_project_set_format (project, GLADE_PROJECT_FORMAT_GTKBUILDER);
}
static void
add_format_options (GtkDialog *dialog,
GladeProject *project)
{
GtkWidget *vbox, *frame;
GtkWidget *glade_radio, *builder_radio;
GtkWidget *label, *alignment;
gchar *string = g_strdup_printf ("<b>%s</b>", _("Select file format"));
frame = gtk_frame_new (NULL);
vbox = gtk_vbox_new (FALSE, 0);
alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 2, 0, 12, 0);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
label = gtk_label_new (string);
g_free (string);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
glade_radio = gtk_radio_button_new_with_label (NULL, "Libglade");
builder_radio = gtk_radio_button_new_with_label_from_widget
(GTK_RADIO_BUTTON (glade_radio), "GtkBuilder");
if (glade_project_get_format (project) == GLADE_PROJECT_FORMAT_GTKBUILDER)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (builder_radio), TRUE);
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_radio), TRUE);
g_signal_connect (G_OBJECT (glade_radio), "clicked",
G_CALLBACK (format_libglade_button_clicked), project);
g_signal_connect (G_OBJECT (builder_radio), "clicked",
G_CALLBACK (format_builder_button_clicked), project);
gtk_box_pack_start (GTK_BOX (vbox), builder_radio, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox), glade_radio, TRUE, TRUE, 2);
gtk_frame_set_label_widget (GTK_FRAME (frame), label);
gtk_container_add (GTK_CONTAINER (alignment), vbox);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_widget_show_all (frame);
gtk_box_pack_end (GTK_BOX (dialog->vbox), frame, FALSE, TRUE, 2);
}
/**
* glade_util_file_dialog_new:
* @title: dialog title
* @parent: the parent #GtkWindow for the dialog
* @project: a #GladeProject used when saving
* @parent: a parent #GtkWindow for the dialog
* @action: a #GladeUtilFileDialogType to say if the dialog will open or save
*
* Returns: a "glade file" file chooser dialog. The caller is responsible
* for showing the dialog
*/
GtkWidget *
glade_util_file_dialog_new (const gchar *title, GtkWindow *parent,
GladeUtilFileDialogType action)
glade_util_file_dialog_new (const gchar *title,
GladeProject *project,
GtkWindow *parent,
GladeUtilFileDialogType action)
{
GtkWidget *file_dialog;
GtkFileFilter *file_filter;
......@@ -503,6 +570,9 @@ glade_util_file_dialog_new (const gchar *title, GtkWindow *parent,
g_return_val_if_fail ((action == GLADE_FILE_DIALOG_ACTION_OPEN ||
action == GLADE_FILE_DIALOG_ACTION_SAVE), NULL);
g_return_val_if_fail ((action != GLADE_FILE_DIALOG_ACTION_SAVE ||
GLADE_IS_PROJECT (project)), NULL);
file_dialog = gtk_file_chooser_dialog_new (title, parent, action,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
......@@ -510,6 +580,10 @@ glade_util_file_dialog_new (const gchar *title, GtkWindow *parent,
GTK_STOCK_OPEN : GTK_STOCK_SAVE,
GTK_RESPONSE_OK,
NULL);
if (action == GLADE_FILE_DIALOG_ACTION_SAVE)
add_format_options (GTK_DIALOG (file_dialog), project);
file_filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (file_filter, "*");
......@@ -518,7 +592,18 @@ glade_util_file_dialog_new (const gchar *title, GtkWindow *parent,
file_filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (file_filter, "*.glade");
gtk_file_filter_set_name (file_filter, _("Glade Files"));
gtk_file_filter_set_name (file_filter, _("Libglade Files"));
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
file_filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (file_filter, "*.ui");
gtk_file_filter_set_name (file_filter, _("GtkBuilder Files"));
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
file_filter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (file_filter, "*.ui");
gtk_file_filter_add_pattern (file_filter, "*.glade");
gtk_file_filter_set_name (file_filter, _("All Glade Files"));
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
......
......@@ -51,6 +51,7 @@ gpointer glade_util_gtk_combo_find (GtkCombo *combo);
GtkWidget *glade_util_file_dialog_new (const gchar *title,
GladeProject *project,
GtkWindow *parent,
GladeUtilFileDialogType action);
......
......@@ -26,7 +26,11 @@
* SECTION:glade-widget-adaptor
* @Short_Description: Adaptor base class to add runtime support for each widget class.
*
* TODO: Add long description.
* The #GladeWidgetAdaptor object is a proxy for widget class support in Glade.
* it is automatically generated from the xml and allows you to override its
* methods in the plugin library for fine grained support on how you load/save
* widgets and handle thier properties in the runtime and more.
*
*/
#include "glade.h"
......
......@@ -1158,8 +1158,9 @@ open_cb (GtkAction *action, GladeWindow *window)
GtkWidget *filechooser;
gchar *path = NULL, *default_path;
filechooser = glade_util_file_dialog_new (_("Open\342\200\246"), GTK_WINDOW (window),
GLADE_FILE_DIALOG_ACTION_OPEN);
filechooser = glade_util_file_dialog_new (_("Open\342\200\246"), NULL,
GTK_WINDOW (window),
GLADE_FILE_DIALOG_ACTION_OPEN);
default_path = g_strdup (get_default_path (window));
......@@ -1279,7 +1280,7 @@ save_as (GladeWindow *window)
if (project == NULL)
return;
filechooser = glade_util_file_dialog_new (_("Save As\342\200\246"),
filechooser = glade_util_file_dialog_new (_("Save As\342\200\246"), project,
GTK_WINDOW (window),
GLADE_FILE_DIALOG_ACTION_SAVE);
......@@ -1454,7 +1455,7 @@ confirm_close_project (GladeWindow *window, GladeProject *project)
gchar *default_path;
filechooser =
glade_util_file_dialog_new (_("Save\342\200\246"),
glade_util_file_dialog_new (_("Save\342\200\246"), project,
GTK_WINDOW (window),
GLADE_FILE_DIALOG_ACTION_SAVE);
......@@ -1691,12 +1692,7 @@ notebook_switch_page_cb (GtkNotebook *notebook,
refresh_title (window);
set_sensitivity_according_to_project (window, project);
/* Set project format here */
action = gtk_action_group_get_action (window->priv->static_actions, "LibgladeFormat");
gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action),
glade_project_get_format (project));
/* switch to the project's inspector */
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), page_num);
......@@ -1773,7 +1769,6 @@ notebook_tab_removed_cb (GtkNotebook *notebook,
{
GladeProject *project;
GladeInspector *inspector;
GtkAction *action;
--window->priv->num_tabs;
......@@ -1803,24 +1798,9 @@ notebook_tab_removed_cb (GtkNotebook *notebook,
project_selection_changed_cb (glade_app_get_project (), window);
if (window->priv->active_view)
{
set_sensitivity_according_to_project
(window, glade_design_view_get_project (window->priv->active_view));
action = gtk_action_group_get_action
(window->priv->static_actions, "LibgladeFormat");
gtk_radio_action_set_current_value
(GTK_RADIO_ACTION (action), glade_project_get_format
(glade_design_view_get_project (window->priv->active_view)));
}
set_sensitivity_according_to_project (window, glade_design_view_get_project (window->priv->active_view));
else
{
action = gtk_action_group_get_action
(window->priv->static_actions, "ProjectFormat");
gtk_action_set_sensitive (action, FALSE);
gtk_action_group_set_sensitive (window->priv->project_actions, FALSE);
}
}
......@@ -1848,8 +1828,8 @@ recent_chooser_item_activated_cb (GtkRecentChooser *chooser, GladeWindow *window
static void
palette_appearance_change_cb (GtkRadioAction *action,
GtkRadioAction *current,
GladeWindow *window)
GtkRadioAction *current,
GladeWindow *window)
{
gint value;
......@@ -1859,24 +1839,6 @@ palette_appearance_change_cb (GtkRadioAction *action,
}
static void
format_change_cb (GtkRadioAction *action,
GtkRadioAction *current,
GladeWindow *window)
{
gint value;
GladeProject *project;
value = gtk_radio_action_get_current_value (action);
if (window->priv->active_view)
{
project = glade_design_view_get_project (window->priv->active_view);
glade_project_set_format (project, value);
}
}
static void
palette_toggle_small_icons_cb (GtkAction *action, GladeWindow *window)
{
......@@ -2190,11 +2152,6 @@ static const gchar ui_info[] =
" <menuitem action='Copy'/>"
" <menuitem action='Paste'/>"
" <menuitem action='Delete'/>"
" <separator/>"
" <menu action='ProjectFormat'>"
" <menuitem action='LibgladeFormat'/>"
" <menuitem action='BuilderFormat'/>"
" </menu>"
" </menu>"
" <menu action='ViewMenu'>"
" <menuitem action='Clipboard'/>"
......@@ -2257,9 +2214,6 @@ static GtkActionEntry static_entries[] = {
{ "Quit", GTK_STOCK_QUIT, NULL, "<control>Q",
N_("Quit the program"), G_CALLBACK (quit_cb) },
/* Edit Menu */
{ "ProjectFormat", NULL, N_("_Project Format") },
/* ViewMenu */
{ "PaletteAppearance", NULL, N_("Palette _Appearance") },
......@@ -2349,7 +2303,7 @@ static GtkToggleActionEntry view_entries[] = {
};
static guint n_view_entries = G_N_ELEMENTS (view_entries);
static GtkRadioActionEntry palette_radio_entries[] = {
static GtkRadioActionEntry radio_entries[] = {
{ "IconsAndLabels", NULL, N_("Text beside icons"), NULL,
N_("Display items as text beside icons"), GLADE_ITEM_ICON_AND_LABEL },
......@@ -2359,21 +2313,8 @@ static GtkRadioActionEntry palette_radio_entries[] = {
{ "LabelsOnly", NULL, N_("_Text only"), NULL,
N_("Display items as text only"), GLADE_ITEM_LABEL_ONLY },
};
static guint n_palette_radio_entries = G_N_ELEMENTS (palette_radio_entries);
static GtkRadioActionEntry format_radio_entries[] = {
{ "LibgladeFormat", NULL, N_("Libglade"), NULL,
N_("Set libglade readable file format"), GLADE_PROJECT_FORMAT_LIBGLADE },
{ "BuilderFormat", NULL, N_("Gtk Builder"), NULL,
N_("Set Gtk Builder file format"), GLADE_PROJECT_FORMAT_GTKBUILDER },
};
static guint n_format_radio_entries = G_N_ELEMENTS (format_radio_entries);
static guint n_radio_entries = G_N_ELEMENTS (radio_entries);
static void
menu_item_selected_cb (GtkWidget *item, GladeWindow *window)
......@@ -2444,16 +2385,10 @@ construct_menu (GladeWindow *window)
view_entries,
n_view_entries,
window);
gtk_action_group_add_radio_actions (window->priv->static_actions, palette_radio_entries,
n_palette_radio_entries, GLADE_ITEM_ICON_ONLY,
gtk_action_group_add_radio_actions (window->priv->static_actions, radio_entries,
n_radio_entries, GLADE_ITEM_ICON_ONLY,
G_CALLBACK (palette_appearance_change_cb), window);
gtk_action_group_add_radio_actions (window->priv->static_actions, format_radio_entries,
n_format_radio_entries,
GLADE_PROJECT_FORMAT_GTKBUILDER,
G_CALLBACK (format_change_cb), window);
window->priv->project_actions = gtk_action_group_new (ACTION_GROUP_PROJECT);
gtk_action_group_set_translation_domain (window->priv->project_actions, GETTEXT_PACKAGE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment