737
761
refresh_notebook_tab_for_project (window, project);
740
gtk_action_group_get_action (window->priv->project_actions, "Save");
741
gtk_action_set_sensitive (action, !glade_project_get_readonly (project));
763
gtk_action_set_sensitive (priv->action.save, !glade_project_get_readonly (project));
743
765
else if (strcmp (spec->name, "has-selection") == 0 && (project == active_project))
746
gtk_action_group_get_action (window->priv->project_actions, "Cut");
747
gtk_action_set_sensitive (action,
748
glade_project_get_has_selection (project));
751
gtk_action_group_get_action (window->priv->project_actions, "Copy");
752
gtk_action_set_sensitive (action,
753
glade_project_get_has_selection (project));
756
gtk_action_group_get_action (window->priv->project_actions, "Delete");
757
gtk_action_set_sensitive (action,
767
gtk_action_set_sensitive (priv->action.cut,
768
glade_project_get_has_selection (project));
769
gtk_action_set_sensitive (priv->action.copy,
770
glade_project_get_has_selection (project));
771
gtk_action_set_sensitive (priv->action.delete,
758
772
glade_project_get_has_selection (project));
763
clipboard_notify_handler_cb (GladeClipboard * clipboard, GParamSpec * spec,
777
clipboard_notify_handler_cb (GladeClipboard *clipboard,
764
779
GladeWindow * window)
768
781
if (strcmp (spec->name, "has-selection") == 0)
771
gtk_action_group_get_action (window->priv->project_actions, "Paste");
772
gtk_action_set_sensitive (action,
783
gtk_action_set_sensitive (window->priv->action.paste,
773
784
glade_clipboard_get_has_selection (clipboard));
778
789
on_pointer_mode_changed (GladeProject *project,
782
793
GladeProject *active_project = get_active_project (window);
783
794
GladeWindowPrivate *priv = window->priv;
795
GladePointerMode mode;
785
797
if (!active_project)
787
gtk_widget_set_sensitive (GTK_WIDGET (priv->selector_button), FALSE);
799
gtk_action_group_set_sensitive (priv->pointer_mode_actions, FALSE);
790
802
else if (active_project != project)
793
gtk_widget_set_sensitive (GTK_WIDGET (priv->selector_button), TRUE);
805
mode = glade_project_get_pointer_mode (project);
806
if (mode == GLADE_POINTER_ADD_WIDGET) return;
795
switch (glade_project_get_pointer_mode (project))
797
case GLADE_POINTER_SELECT:
798
glade_project_set_add_item (active_project, NULL);
799
gtk_toggle_tool_button_set_active (priv->selector_button, TRUE);
801
case GLADE_POINTER_DRAG_RESIZE:
802
gtk_toggle_tool_button_set_active (priv->drag_resize_button, TRUE);
804
case GLADE_POINTER_MARGIN_EDIT:
805
gtk_toggle_tool_button_set_active (priv->margin_edit_button, TRUE);
807
case GLADE_POINTER_ALIGN_EDIT:
808
gtk_toggle_tool_button_set_active (priv->align_edit_button, TRUE);
811
gtk_toggle_tool_button_set_active (priv->selector_button, FALSE);
808
gtk_action_group_set_sensitive (priv->pointer_mode_actions, TRUE);
809
gtk_radio_action_set_current_value (GTK_RADIO_ACTION (priv->action.selector),
817
814
set_sensitivity_according_to_project (GladeWindow *window,
818
815
GladeProject *project)
822
action = gtk_action_group_get_action (window->priv->project_actions, "Save");
823
gtk_action_set_sensitive (action, !glade_project_get_readonly (project));
825
action = gtk_action_group_get_action (window->priv->project_actions, "Cut");
826
gtk_action_set_sensitive (action, glade_project_get_has_selection (project));
828
action = gtk_action_group_get_action (window->priv->project_actions, "Copy");
829
gtk_action_set_sensitive (action, glade_project_get_has_selection (project));
831
action = gtk_action_group_get_action (window->priv->project_actions, "Paste");
832
gtk_action_set_sensitive (action,
817
GladeWindowPrivate *priv = window->priv;
819
gtk_action_set_sensitive (priv->action.save, !glade_project_get_readonly (project));
821
gtk_action_set_sensitive (priv->action.cut, glade_project_get_has_selection (project));
823
gtk_action_set_sensitive (priv->action.copy, glade_project_get_has_selection (project));
825
gtk_action_set_sensitive (priv->action.paste,
833
826
glade_clipboard_get_has_selection
834
827
(glade_app_get_clipboard ()));
837
gtk_action_group_get_action (window->priv->project_actions, "Delete");
838
gtk_action_set_sensitive (action, glade_project_get_has_selection (project));
829
gtk_action_set_sensitive (priv->action.delete, glade_project_get_has_selection (project));
840
831
refresh_next_prev_project_sensitivity (window);
845
recent_add (GladeWindow * window, const gchar * path)
835
recent_add (GladeWindow *window, const gchar *path)
847
837
GtkRecentData *recent_data;
2044
1983
glade_util_url_show (URL_DEVELOPER_MANUAL);
2048
about_cb (GtkAction * action, GladeWindow * window)
1987
on_about_action_activate (GtkAction *action, GladeWindow *window)
2050
static const gchar *const authors[] = { "Chema Celorio <chema@ximian.com>",
2051
"Joaquin Cuenca Abela <e98cuenc@yahoo.com>",
2052
"Paolo Borelli <pborelli@katamail.com>",
2053
"Archit Baweja <bighead@users.sourceforge.net>",
2054
"Shane Butler <shane_b@operamail.com>",
2055
"Tristan Van Berkom <tvb@gnome.org>",
2056
"Ivan Wong <email@ivanwong.info>",
2057
"Juan Pablo Ugarte <juanpablougarte@gmail.com>",
2058
"Vincent Geddes <vincent.geddes@gmail.com>",
2062
static const gchar *const artists[] = { "Vincent Geddes <vgeddes@gnome.org>",
2063
"Andreas Nilsson <andreas@andreasn.se>",
2067
static const gchar *const documenters[] =
2068
{ "GNOME Documentation Team <gnome-doc-list@gnome.org>",
2069
"Sun GNOME Documentation Team <gdocteam@sun.com>",
2073
static const gchar license[] =
2074
N_("Glade is free software; you can redistribute it and/or modify "
2075
"it under the terms of the GNU General Public License as "
2076
"published by the Free Software Foundation; either version 2 of the "
2077
"License, or (at your option) any later version."
2079
"Glade is distributed in the hope that it will be useful, "
2080
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
2081
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
2082
"GNU General Public License for more details."
2084
"You should have received a copy of the GNU General Public License "
2085
"along with Glade; if not, write to the Free Software "
2086
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
2087
"MA 02110-1301, USA.");
2089
static const gchar copyright[] =
2090
"Copyright \xc2\xa9 2001-2006 Ximian, Inc.\n"
2091
"Copyright \xc2\xa9 2001-2006 Joaquin Cuenca Abela, Paolo Borelli, et al.\n"
2092
"Copyright \xc2\xa9 2001-2010 Tristan Van Berkom, Juan Pablo Ugarte, et al.";
2094
gtk_show_about_dialog (GTK_WINDOW (window),
2095
"name", g_get_application_name (),
2096
"logo-icon-name", "glade",
2099
"documenters", documenters,
2100
"translator-credits", _("translator-credits"),
2102
_("A user interface designer for GTK+ and GNOME."),
2103
"license", _(license), "wrap-license", TRUE,
2104
"copyright", copyright, "version", PACKAGE_VERSION,
2105
"website", PACKAGE_URL, NULL);
1989
GladeWindowPrivate *priv = GLADE_WINDOW_GET_PRIVATE (window);
1991
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (priv->about_dialog), PACKAGE_VERSION);
1993
gtk_window_present (priv->about_dialog);
2108
static const gchar ui_info[] =
2110
" <menubar name='MenuBar'>"
2111
" <menu action='FileMenu'>"
2112
" <menuitem action='New'/>"
2113
" <menuitem action='Open'/>"
2114
" <menuitem action='OpenRecent'/>"
2116
" <menuitem action='Save'/>"
2117
" <menuitem action='SaveAs'/>"
2119
" <menuitem action='Properties'/>"
2121
" <menuitem action='Close'/>"
2122
" <menuitem action='Quit'/>"
2124
" <menu action='EditMenu'>"
2125
" <menuitem action='Undo'/>"
2126
" <menuitem action='Redo'/>"
2128
" <menuitem action='Cut'/>"
2129
" <menuitem action='Copy'/>"
2130
" <menuitem action='Paste'/>"
2131
" <menuitem action='Delete'/>"
2133
" <menu action='ViewMenu'>"
2134
" <menuitem action='ToolbarVisible'/>"
2135
" <menuitem action='StatusbarVisible'/>"
2136
" <menuitem action='ProjectTabsVisible'/>"
2137
" <menu action='PaletteAppearance'>"
2138
" <menuitem action='IconsAndLabels'/>"
2139
" <menuitem action='IconsOnly'/>"
2140
" <menuitem action='LabelsOnly'/>"
2142
" <menuitem action='UseSmallIcons'/>"
2145
" <menuitem action='DockPalette'/>"
2146
" <menuitem action='DockInspector'/>"
2147
" <menuitem action='DockEditor'/>"
2149
" <menu action='ProjectMenu'>"
2150
" <menuitem action='PreviousProject'/>"
2151
" <menuitem action='NextProject'/>"
2153
" <placeholder name='ProjectsListPlaceholder'/>"
2155
" <menu action='HelpMenu'>"
2156
" <menuitem action='DeveloperReference'/>"
2158
" <menuitem action='About'/>"
2161
" <toolbar name='ToolBar'>"
2162
" <toolitem action='New'/>"
2163
" <toolitem action='Open'/>"
2164
" <toolitem action='Save'/>"
2166
" <toolitem action='Cut'/>"
2167
" <toolitem action='Copy'/>"
2168
" <toolitem action='Paste'/>"
2169
" </toolbar>" "</ui>";
2171
static GtkActionEntry static_entries[] = {
2172
{"FileMenu", NULL, N_("_File")},
2173
{"EditMenu", NULL, N_("_Edit")},
2174
{"ViewMenu", NULL, N_("_View")},
2175
{"ProjectMenu", NULL, N_("_Projects")},
2176
{"HelpMenu", NULL, N_("_Help")},
2177
{"UndoMenu", NULL, NULL},
2178
{"RedoMenu", NULL, NULL},
2181
{"New", GTK_STOCK_NEW, NULL, "<control>N",
2182
N_("Create a new project"), G_CALLBACK (new_cb)},
2184
{"Open", GTK_STOCK_OPEN, N_("_Open\342\200\246"), "<control>O",
2185
N_("Open a project"), G_CALLBACK (open_cb)},
2187
{"OpenRecent", NULL, N_("Open _Recent")},
2189
{"Quit", GTK_STOCK_QUIT, NULL, "<control>Q",
2190
N_("Quit the program"), G_CALLBACK (quit_cb)},
2193
{"PaletteAppearance", NULL, N_("Palette _Appearance")},
2196
{"About", GTK_STOCK_ABOUT, NULL, NULL,
2197
N_("About this application"), G_CALLBACK (about_cb)},
2199
{"DeveloperReference", NULL, N_("_Developer Reference"), NULL,
2200
N_("Display the developer reference manual"),
2201
G_CALLBACK (show_developer_manual_cb)}
2204
static guint n_static_entries = G_N_ELEMENTS (static_entries);
2206
static GtkActionEntry project_entries[] = {
2209
{"Save", GTK_STOCK_SAVE, NULL, "<control>S",
2210
N_("Save the current project"), G_CALLBACK (save_cb)},
2212
{"SaveAs", GTK_STOCK_SAVE_AS, N_("Save _As\342\200\246"), NULL,
2213
N_("Save the current project with a different name"),
2214
G_CALLBACK (save_as_cb)},
2216
{"Close", GTK_STOCK_CLOSE, NULL, "<control>W",
2217
N_("Close the current project"), G_CALLBACK (close_cb)},
2220
{"Undo", GTK_STOCK_UNDO, NULL, "<control>Z",
2221
N_("Undo the last action"), G_CALLBACK (undo_cb)},
2223
{"Redo", GTK_STOCK_REDO, NULL, "<shift><control>Z",
2224
N_("Redo the last action"), G_CALLBACK (redo_cb)},
2226
{"Cut", GTK_STOCK_CUT, NULL, NULL,
2227
N_("Cut the selection"), G_CALLBACK (cut_cb)},
2229
{"Copy", GTK_STOCK_COPY, NULL, NULL,
2230
N_("Copy the selection"), G_CALLBACK (copy_cb)},
2232
{"Paste", GTK_STOCK_PASTE, NULL, NULL,
2233
N_("Paste the clipboard"), G_CALLBACK (paste_cb)},
2235
{"Delete", GTK_STOCK_DELETE, NULL, "Delete",
2236
N_("Delete the selection"), G_CALLBACK (delete_cb)},
2238
{"Properties", GTK_STOCK_PROPERTIES, NULL, "<control>P",
2239
N_("Edit project properties"), G_CALLBACK (properties_cb)},
2242
{"PreviousProject", NULL, N_("_Previous Project"), "<control>Page_Up",
2243
N_("Activate previous project"), G_CALLBACK (previous_project_cb)},
2245
{"NextProject", NULL, N_("_Next Project"), "<control>Page_Down",
2246
N_("Activate next project"), G_CALLBACK (next_project_cb)}
2251
static guint n_project_entries = G_N_ELEMENTS (project_entries);
2253
static GtkToggleActionEntry view_entries[] = {
2255
{"UseSmallIcons", NULL, N_("_Use Small Icons"), NULL,
2256
N_("Show items using small icons"),
2257
G_CALLBACK (palette_toggle_small_icons_cb), FALSE},
2259
{"DockPalette", NULL, N_("Dock _Palette"), NULL,
2260
N_("Dock the palette into the main window"),
2261
G_CALLBACK (toggle_dock_cb), TRUE},
2263
{"DockInspector", NULL, N_("Dock _Inspector"), NULL,
2264
N_("Dock the inspector into the main window"),
2265
G_CALLBACK (toggle_dock_cb), TRUE},
2267
{"DockEditor", NULL, N_("Dock Prop_erties"), NULL,
2268
N_("Dock the editor into the main window"),
2269
G_CALLBACK (toggle_dock_cb), TRUE},
2271
{"ToolbarVisible", NULL, N_("Tool_bar"), NULL,
2272
N_("Show the toolbar"),
2273
G_CALLBACK (toggle_toolbar_cb), TRUE},
2275
{"StatusbarVisible", NULL, N_("_Statusbar"), NULL,
2276
N_("Show the statusbar"),
2277
G_CALLBACK (toggle_statusbar_cb), TRUE},
2279
{"ProjectTabsVisible", NULL, N_("Project _Tabs"), NULL,
2280
N_("Show notebook tabs for loaded projects"),
2281
G_CALLBACK (toggle_tabs_cb), TRUE},
2285
static guint n_view_entries = G_N_ELEMENTS (view_entries);
2287
static GtkRadioActionEntry radio_entries[] = {
2289
{"IconsAndLabels", NULL, N_("Text _beside icons"), NULL,
2290
N_("Display items as text beside icons"), GLADE_ITEM_ICON_AND_LABEL},
2292
{"IconsOnly", NULL, N_("_Icons only"), NULL,
2293
N_("Display items as icons only"), GLADE_ITEM_ICON_ONLY},
2295
{"LabelsOnly", NULL, N_("_Text only"), NULL,
2296
N_("Display items as text only"), GLADE_ITEM_LABEL_ONLY},
2299
static guint n_radio_entries = G_N_ELEMENTS (radio_entries);
2302
menu_item_selected_cb (GtkWidget * item, GladeWindow * window)
1997
menu_item_selected_cb (GtkWidget *item, GladeWindow *window)
2307
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (item));
2308
g_object_get (G_OBJECT (action), "tooltip", &tooltip, NULL);
2310
if (tooltip != NULL)
1999
gchar *tooltip = gtk_widget_get_tooltip_text (item);
2311
2002
gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar),
2312
2003
window->priv->statusbar_menu_context_id, tooltip);
2326
ui_connect_proxy_cb (GtkUIManager * ui,
2328
GtkWidget * proxy, GladeWindow * window)
2017
menu_item_connect (GtkWidget *item, GtkAction *action, GladeWindow *window)
2330
if (GTK_IS_MENU_ITEM (proxy))
2019
if (GTK_IS_MENU_ITEM (item))
2332
g_signal_connect (G_OBJECT (proxy), "select",
2022
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (item));
2027
g_object_get (G_OBJECT (action), "tooltip", &tooltip, NULL);
2028
gtk_widget_set_tooltip_text (item, tooltip);
2029
/* yeah dont actually show tooltips, we use the to push them to the status bar */
2030
gtk_widget_set_has_tooltip (item, FALSE);
2035
g_signal_connect (item, "select",
2333
2036
G_CALLBACK (menu_item_selected_cb), window);
2334
g_signal_connect (G_OBJECT (proxy), "deselect",
2037
g_signal_connect (item, "deselect",
2335
2038
G_CALLBACK (menu_item_deselected_cb), window);
2340
ui_disconnect_proxy_cb (GtkUIManager * manager,
2342
GtkWidget * proxy, GladeWindow * window)
2344
if (GTK_IS_MENU_ITEM (proxy))
2346
g_signal_handlers_disconnect_by_func
2347
(proxy, G_CALLBACK (menu_item_selected_cb), window);
2348
g_signal_handlers_disconnect_by_func
2349
(proxy, G_CALLBACK (menu_item_deselected_cb), window);
2354
construct_menu (GladeWindow * window)
2356
GError *error = NULL;
2358
window->priv->static_actions = gtk_action_group_new (ACTION_GROUP_STATIC);
2359
gtk_action_group_set_translation_domain (window->priv->static_actions,
2362
gtk_action_group_add_actions (window->priv->static_actions,
2363
static_entries, n_static_entries, window);
2364
gtk_action_group_add_toggle_actions (window->priv->static_actions,
2365
view_entries, n_view_entries, window);
2366
gtk_action_group_add_radio_actions (window->priv->static_actions,
2367
radio_entries, n_radio_entries,
2368
GLADE_ITEM_ICON_ONLY,
2369
G_CALLBACK (palette_appearance_change_cb),
2372
window->priv->project_actions = gtk_action_group_new (ACTION_GROUP_PROJECT);
2373
gtk_action_group_set_translation_domain (window->priv->project_actions,
2376
gtk_action_group_add_actions (window->priv->project_actions,
2377
project_entries, n_project_entries, window);
2379
window->priv->projects_list_menu_actions =
2380
gtk_action_group_new (ACTION_GROUP_PROJECTS_LIST_MENU);
2381
gtk_action_group_set_translation_domain (window->priv->
2382
projects_list_menu_actions,
2385
window->priv->ui = gtk_ui_manager_new ();
2387
g_signal_connect (G_OBJECT (window->priv->ui), "connect-proxy",
2388
G_CALLBACK (ui_connect_proxy_cb), window);
2389
g_signal_connect (G_OBJECT (window->priv->ui), "disconnect-proxy",
2390
G_CALLBACK (ui_disconnect_proxy_cb), window);
2392
gtk_ui_manager_insert_action_group (window->priv->ui,
2393
window->priv->static_actions, 0);
2394
gtk_ui_manager_insert_action_group (window->priv->ui,
2395
window->priv->project_actions, 1);
2396
gtk_ui_manager_insert_action_group (window->priv->ui,
2397
window->priv->projects_list_menu_actions,
2400
gtk_window_add_accel_group (GTK_WINDOW (window),
2401
gtk_ui_manager_get_accel_group (window->priv->
2404
glade_app_set_accel_group (gtk_ui_manager_get_accel_group (window->priv->ui));
2406
if (!gtk_ui_manager_add_ui_from_string
2407
(window->priv->ui, ui_info, -1, &error))
2409
g_message ("Building menus failed: %s", error->message);
2410
g_error_free (error);
2413
return gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar");
2043
menu_item_disconnect (GtkWidget *item, GladeWindow *window)
2045
if (GTK_IS_MENU_ITEM (item))
2047
g_signal_handlers_disconnect_by_func
2048
(item, G_CALLBACK (menu_item_selected_cb), window);
2049
g_signal_handlers_disconnect_by_func
2050
(item, G_CALLBACK (menu_item_deselected_cb), window);
2055
on_actiongroup_connect_proxy (GtkActionGroup *action_group,
2058
GladeWindow *window)
2060
menu_item_connect (proxy, action, window);
2064
on_actiongroup_disconnect_proxy (GtkActionGroup *action_group,
2067
GladeWindow *window)
2069
menu_item_disconnect (proxy, window);
2073
on_recent_menu_insert (GtkMenuShell *menu_shell,
2076
GladeWindow *window)
2078
menu_item_connect (child, NULL, window);
2082
on_recent_menu_remove (GtkContainer *container,
2084
GladeWindow *window)
2086
menu_item_disconnect (widget, window);
2090
recent_menu_setup_callbacks (GtkWidget *menu, GladeWindow *window)
2092
GList *l, *list = gtk_container_get_children (GTK_CONTAINER (menu));
2094
for (l = list; l; l = g_list_next (l))
2095
menu_item_connect (l->data, NULL, window);
2101
action_group_setup_callbacks (GtkActionGroup *action_group, GladeWindow *window)
2103
GList *l, *list = gtk_action_group_list_actions (action_group);
2105
for (l = list; l; l = g_list_next (l))
2107
GtkAction *action = l->data;
2108
GSList *p, *proxies = gtk_action_get_proxies (action);
2109
gboolean is_recent = GTK_IS_RECENT_ACTION (action);
2111
for (p = proxies; p; p = g_slist_next (p))
2113
GtkWidget *submenu, *proxy = p->data;
2115
menu_item_connect (proxy, action, window);
2117
if (is_recent && GTK_IS_MENU_ITEM (proxy) &&
2118
(submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy))))
2119
recent_menu_setup_callbacks (submenu, window);
3301
2894
dock->maximized = FALSE;
2898
on_quit_action_activate (GtkAction *action, GladeWindow *window)
2900
GList *list, *projects;
2902
projects = g_list_copy (glade_app_get_projects ());
2904
for (list = projects; list; list = list->next)
2906
GladeProject *project = GLADE_PROJECT (list->data);
2908
if (glade_project_get_modified (project))
2910
gboolean quit = confirm_close_project (window, project);
2913
g_list_free (projects);
2919
for (list = projects; list; list = list->next)
2921
GladeProject *project = GLADE_PROJECT (glade_app_get_projects ()->data);
2922
do_close (window, project);
2925
glade_window_config_save (window);
2927
g_list_free (projects);
3305
glade_window_init (GladeWindow * window)
2934
glade_window_init (GladeWindow *window)
3307
2936
GladeWindowPrivate *priv;
3314
GtkWidget *dockitem;
3317
GtkAction *undo_action, *redo_action;
3319
2938
window->priv = priv = GLADE_WINDOW_GET_PRIVATE (window);
3321
2940
priv->default_path = NULL;
3323
2942
priv->app = glade_app_new ();
3325
vbox = gtk_vbox_new (FALSE, 0);
2946
#define GET_OBJECT(b,c,o) c(gtk_builder_get_object(b,o)) /*;g_warn_if_fail(gtk_builder_get_object(b,o))*/
2949
glade_window_constructed (GObject *object)
2951
GladeWindowPrivate *priv = GLADE_WINDOW_GET_PRIVATE (object);
2952
GtkBuilder *builder;
2953
GladeWindow *window;
2954
GError *error = NULL;
2956
GtkActionGroup *group;
2959
G_OBJECT_CLASS (glade_window_parent_class)->constructed (object);
2962
#if HAVE_GTK_BUILDER_ADD_FROM_RESOURCE
2963
builder = gtk_builder_new ();
2964
if (gtk_builder_add_from_resource (builder, "/org/gnome/glade/glade.glade", &error) == 0)
2966
g_warning ("gtk_builder_add_from_resource() failed %s", (error) ? error->message : "");
2971
/*TODO: remove this once we depend on gtk 3.4 */
2972
GBytes *glade_ui = g_resources_lookup_data ("/org/gnome/glade/glade.glade",
2973
G_RESOURCE_LOOKUP_FLAGS_NONE,
2975
if (glade_ui == NULL) return;
2977
builder = gtk_builder_new ();
2978
gtk_builder_add_from_string (builder, g_bytes_get_data (glade_ui, NULL), -1, NULL);
2982
window = GLADE_WINDOW (object);
2984
priv->projects_list_menu_actions = GET_OBJECT (builder, GTK_ACTION_GROUP, "project_list_actiongroup");
2985
g_object_ref_sink (priv->projects_list_menu_actions);
2988
priv->recent_manager = gtk_recent_manager_get_default ();
2990
GtkRecentFilter *filter = gtk_recent_filter_new ();
2991
gtk_recent_filter_add_application (filter, g_get_application_name ());
2992
gtk_recent_chooser_set_filter (GET_OBJECT (builder, GTK_RECENT_CHOOSER, "open_recent_action"),
2996
/* Fetch pointers */
2997
vbox = GET_OBJECT (builder, GTK_WIDGET, "main_box");
2998
priv->about_dialog = GET_OBJECT (builder, GTK_WINDOW, "about_dialog");
2999
priv->preferences_dialog = GET_OBJECT (builder, GTK_WINDOW, "preferences_dialog");
3001
priv->center_pane = GET_OBJECT (builder, GTK_WIDGET, "center_paned");
3002
priv->left_pane = GET_OBJECT (builder, GTK_WIDGET, "left_paned");
3003
priv->right_pane = GET_OBJECT (builder, GTK_WIDGET, "right_paned");
3005
priv->notebook = GET_OBJECT (builder, GTK_WIDGET, "notebook");
3006
priv->palettes_notebook = GET_OBJECT (builder, GTK_WIDGET, "palettes_notebook");
3007
priv->inspectors_notebook = GET_OBJECT (builder, GTK_WIDGET, "inspectors_notebook");
3008
priv->editor = GET_OBJECT (builder, GLADE_EDITOR, "editor");
3009
priv->statusbar = GET_OBJECT (builder, GTK_WIDGET, "statusbar");
3010
priv->toolbar = GET_OBJECT (builder, GTK_WIDGET, "toolbar");
3011
priv->project_menu = GET_OBJECT (builder, GTK_MENU_SHELL, "project_menu");
3013
priv->undo = GET_OBJECT (builder, GTK_TOOL_ITEM, "undo_toolbutton");
3014
priv->redo = GET_OBJECT (builder, GTK_TOOL_ITEM, "redo_toolbutton");
3016
priv->accelgroup = GTK_ACCEL_GROUP (gtk_builder_get_object (builder, "accelgroup"));
3017
gtk_window_add_accel_group (GTK_WINDOW (window), priv->accelgroup);
3020
priv->project_actions = GET_OBJECT (builder, GTK_ACTION_GROUP, "project_actiongroup");
3021
action_group_setup_callbacks (priv->project_actions, window);
3022
g_object_ref_sink (priv->project_actions);
3024
priv->pointer_mode_actions = GET_OBJECT (builder, GTK_ACTION_GROUP, "pointer_mode_actiongroup");
3025
action_group_setup_callbacks (priv->pointer_mode_actions, window);
3026
g_object_ref_sink (priv->pointer_mode_actions);
3028
group = GET_OBJECT (builder, GTK_ACTION_GROUP, "static_actiongroup");
3029
action_group_setup_callbacks (group, window);
3030
g_object_ref_sink (group);
3032
group = GET_OBJECT (builder, GTK_ACTION_GROUP, "view_actiongroup");
3033
action_group_setup_callbacks (group, window);
3034
g_object_ref_sink (group);
3037
priv->action.save = GET_OBJECT (builder, GTK_ACTION, "save_action");
3038
priv->action.quit = GET_OBJECT (builder, GTK_ACTION, "quit_action");
3039
priv->action.undo = GET_OBJECT (builder, GTK_ACTION, "undo_action");
3040
priv->action.redo = GET_OBJECT (builder, GTK_ACTION, "redo_action");
3041
priv->action.cut = GET_OBJECT (builder, GTK_ACTION, "cut_action");
3042
priv->action.copy = GET_OBJECT (builder, GTK_ACTION, "copy_action");
3043
priv->action.paste = GET_OBJECT (builder, GTK_ACTION, "paste_action");
3044
priv->action.delete = GET_OBJECT (builder, GTK_ACTION, "delete_action");
3045
priv->action.previous_project = GET_OBJECT (builder, GTK_ACTION, "previous_project_action");
3046
priv->action.next_project = GET_OBJECT (builder, GTK_ACTION, "next_project_action");
3047
priv->action.use_small_icons = GET_OBJECT (builder, GTK_ACTION, "use_small_icons_action");
3048
priv->action.icons_and_labels = GET_OBJECT (builder, GTK_ACTION, "icons_and_labels_radioaction");
3049
priv->action.toolbar_visible = GET_OBJECT (builder, GTK_ACTION, "toolbar_visible_action");
3050
priv->action.project_tabs_visible = GET_OBJECT (builder, GTK_ACTION, "project_tabs_visible_action");
3051
priv->action.statusbar_visible = GET_OBJECT (builder, GTK_ACTION, "statusbar_visible_action");
3052
priv->action.selector = GET_OBJECT (builder, GTK_ACTION, "selector_radioaction");
3326
3054
gtk_container_add (GTK_CONTAINER (window), vbox);
3329
priv->editor = GLADE_EDITOR (glade_editor_new ());
3330
gtk_widget_show (GTK_WIDGET (priv->editor));
3331
g_object_ref_sink (G_OBJECT (priv->editor));
3334
menubar = construct_menu (window);
3335
gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0);
3336
gtk_widget_show (menubar);
3339
priv->toolbar = gtk_ui_manager_get_widget (priv->ui, "/ToolBar");
3340
gtk_style_context_add_class (gtk_widget_get_style_context (priv->toolbar),
3341
GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
3342
gtk_box_pack_start (GTK_BOX (vbox), priv->toolbar, FALSE, TRUE, 0);
3343
gtk_widget_show (priv->toolbar);
3345
/* undo/redo buttons */
3346
priv->undo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_UNDO);
3347
priv->redo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_REDO);
3348
gtk_widget_show (GTK_WIDGET (priv->undo));
3349
gtk_widget_show (GTK_WIDGET (priv->redo));
3350
gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON
3352
_("Go back in undo history"));
3353
gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON
3355
_("Go forward in undo history"));
3357
sep = GTK_WIDGET (gtk_separator_tool_item_new ());
3358
gtk_widget_show (sep);
3359
gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (sep), 3);
3360
gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (priv->undo),
3362
gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (priv->redo),
3365
undo_action = gtk_ui_manager_get_action (priv->ui, "/MenuBar/EditMenu/Undo");
3366
redo_action = gtk_ui_manager_get_action (priv->ui, "/MenuBar/EditMenu/Redo");
3368
gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->undo),
3370
gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->redo),
3374
hpaned1 = gtk_hpaned_new ();
3375
hpaned2 = gtk_hpaned_new ();
3376
vpaned = gtk_vpaned_new ();
3377
priv->center_pane = hpaned1;
3378
priv->left_pane = hpaned2;
3379
priv->right_pane = vpaned;
3381
gtk_container_set_border_width (GTK_CONTAINER (hpaned1), 2);
3383
gtk_box_pack_start (GTK_BOX (vbox), hpaned1, TRUE, TRUE, 0);
3384
gtk_paned_pack1 (GTK_PANED (hpaned1), hpaned2, TRUE, FALSE);
3385
gtk_paned_pack2 (GTK_PANED (hpaned1), vpaned, FALSE, FALSE);
3387
/* divider position between tree and editor */
3388
gtk_paned_set_position (GTK_PANED (vpaned), 150);
3390
gtk_widget_show_all (hpaned1);
3391
gtk_widget_show_all (hpaned2);
3392
gtk_widget_show_all (vpaned);
3395
priv->notebook = gtk_notebook_new ();
3396
gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE);
3398
/* Show tabs (user preference) */
3399
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), TRUE);
3400
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
3401
gtk_paned_pack2 (GTK_PANED (hpaned2), priv->notebook, TRUE, FALSE);
3402
gtk_widget_show (priv->notebook);
3405
priv->palettes_notebook = gtk_notebook_new ();
3406
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->palettes_notebook), FALSE);
3407
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->palettes_notebook), FALSE);
3408
gtk_paned_pack1 (GTK_PANED (hpaned2), priv->palettes_notebook, FALSE, FALSE);
3409
3057
setup_dock (&priv->docks[DOCK_PALETTE], priv->palettes_notebook, 200, 540,
3410
_("Palette"), "palette", hpaned2, TRUE);
3411
gtk_widget_show (priv->palettes_notebook);
3414
priv->inspectors_notebook = gtk_notebook_new ();
3415
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->inspectors_notebook), FALSE);
3416
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->inspectors_notebook), FALSE);
3417
gtk_widget_show (priv->inspectors_notebook);
3418
gtk_paned_pack1 (GTK_PANED (vpaned), priv->inspectors_notebook, FALSE, FALSE);
3058
_("Palette"), "palette", priv->left_pane, TRUE);
3419
3059
setup_dock (&priv->docks[DOCK_INSPECTOR], priv->inspectors_notebook, 300, 540,
3420
_("Inspector"), "inspector", vpaned, TRUE);
3423
dockitem = GTK_WIDGET (priv->editor);
3424
gtk_paned_pack2 (GTK_PANED (vpaned), dockitem, TRUE, FALSE);
3425
gtk_widget_show_all (dockitem);
3426
setup_dock (&priv->docks[DOCK_EDITOR], dockitem, 500, 700,
3427
_("Properties"), "properties", vpaned, FALSE);
3429
show_dock_first_time (window, DOCK_PALETTE, "DockPalette");
3430
show_dock_first_time (window, DOCK_INSPECTOR, "DockInspector");
3431
show_dock_first_time (window, DOCK_EDITOR, "DockEditor");
3060
_("Inspector"), "inspector", priv->right_pane, TRUE);
3061
setup_dock (&priv->docks[DOCK_EDITOR], GTK_WIDGET (priv->editor), 500, 700,
3062
_("Properties"), "properties", priv->right_pane, FALSE);
3063
show_dock_first_time (window, DOCK_PALETTE, GET_OBJECT (builder, GTK_ACTION, "dock_palette_action"));
3064
show_dock_first_time (window, DOCK_INSPECTOR, GET_OBJECT (builder, GTK_ACTION, "dock_inspector_action"));
3065
show_dock_first_time (window, DOCK_EDITOR, GET_OBJECT (builder, GTK_ACTION, "dock_editor_action"));
3433
3067
/* status bar */
3434
priv->statusbar = gtk_statusbar_new ();
3435
priv->statusbar_menu_context_id =
3436
gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "menu");
3437
priv->statusbar_actions_context_id =
3438
gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "actions");
3439
gtk_box_pack_end (GTK_BOX (vbox), priv->statusbar, FALSE, TRUE, 0);
3440
gtk_widget_show (priv->statusbar);
3443
gtk_widget_show (vbox);
3446
priv->recent_manager = gtk_recent_manager_get_default ();
3448
priv->recent_menu = create_recent_chooser_menu (window, priv->recent_manager);
3450
g_signal_connect (priv->recent_menu,
3452
G_CALLBACK (recent_chooser_item_activated_cb), window);
3454
widget = gtk_ui_manager_get_widget (priv->ui, "/MenuBar/FileMenu/OpenRecent");
3455
gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), priv->recent_menu);
3457
/* palette selector & drag/resize buttons */
3458
sep = GTK_WIDGET (gtk_separator_tool_item_new ());
3459
gtk_widget_show (GTK_WIDGET (sep));
3460
gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (sep), -1);
3462
priv->selector_button = create_tool_button (GTK_TOOLBAR (priv->toolbar),
3465
_("Select widgets in the workspace"),
3466
GLADE_POINTER_SELECT);
3467
priv->drag_resize_button = create_tool_button (GTK_TOOLBAR (priv->toolbar),
3468
priv->selector_button,
3470
_("Drag and resize widgets in the workspace"),
3471
GLADE_POINTER_DRAG_RESIZE);
3472
priv->margin_edit_button = create_tool_button (GTK_TOOLBAR (priv->toolbar),
3473
priv->selector_button,
3475
_("Edit widget margins"),
3476
GLADE_POINTER_MARGIN_EDIT);
3477
priv->align_edit_button = create_tool_button (GTK_TOOLBAR (priv->toolbar),
3478
priv->selector_button,
3479
_("Alignment Edit"),
3480
_("Edit widget alignment"),
3481
GLADE_POINTER_ALIGN_EDIT);
3068
priv->statusbar_menu_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "menu");
3069
priv->statusbar_actions_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "actions");
3483
3071
/* support for opening a file by dragging onto the project window */
3484
3072
gtk_drag_dest_set (GTK_WIDGET (window),
3515
3092
glade_app_set_window (GTK_WIDGET (window));
3094
gtk_builder_connect_signals (builder, window);
3517
3096
glade_window_config_load (window);
3519
3098
#ifdef MAC_INTEGRATION
3521
/* Fix up the menubar for MacOSX Quartz builds */
3523
GtkOSXApplication *theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
3524
gtk_widget_hide (menubar);
3525
gtk_osxapplication_set_menu_bar(theApp, GTK_MENU_SHELL(menubar));
3527
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/FileMenu/Quit");
3528
gtk_widget_hide (widget);
3530
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/HelpMenu/About");
3531
gtk_osxapplication_insert_app_menu_item (theApp, widget, 0);
3532
sep = gtk_separator_menu_item_new();
3534
gtk_osxapplication_insert_app_menu_item (theApp, sep, 1);
3537
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/FileMenu/Properties");
3538
gtk_osxapplication_insert_app_menu_item (theApp, widget, 2);
3539
sep = gtk_separator_menu_item_new();
3541
gtk_osxapplication_insert_app_menu_item (theApp, sep, 3);
3544
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/HelpMenu");
3545
gtk_osxapplication_set_help_menu(theApp, GTK_MENU_ITEM(widget));
3547
g_signal_connect(theApp, "NSApplicationWillTerminate",
3548
G_CALLBACK(quit_cb), window);
3550
gtk_osxapplication_ready(theApp);
3100
/* Fix up the menubar for MacOSX Quartz builds */
3101
GtkWidget *menubar =GTK_WIDGET (gtk_builder_get_object (builder, "menubar"));
3104
GtkOSXApplication *theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
3105
gtk_widget_hide (menubar);
3106
gtk_osxapplication_set_menu_bar(theApp, GTK_MENU_SHELL(menubar));
3108
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/FileMenu/Quit");
3109
gtk_widget_hide (widget);
3111
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/HelpMenu/About");
3112
gtk_osxapplication_insert_app_menu_item (theApp, widget, 0);
3113
sep = gtk_separator_menu_item_new();
3115
gtk_osxapplication_insert_app_menu_item (theApp, sep, 1);
3118
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/FileMenu/Properties");
3119
gtk_osxapplication_insert_app_menu_item (theApp, widget, 2);
3120
sep = gtk_separator_menu_item_new();
3122
gtk_osxapplication_insert_app_menu_item (theApp, sep, 3);
3125
gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/HelpMenu");
3126
gtk_osxapplication_set_help_menu(theApp, GTK_MENU_ITEM(widget));
3128
g_signal_connect(theApp, "NSApplicationWillTerminate",
3129
G_CALLBACK(on_quit_action_activate), window);
3131
gtk_osxapplication_ready(theApp);
3134
g_object_unref (builder);
3558
glade_window_class_init (GladeWindowClass * klass)
3138
glade_window_class_init (GladeWindowClass *klass)
3560
3140
GObjectClass *object_class;
3561
3141
GtkWidgetClass *widget_class;