Exemple #1
0
/* callback for gtkpod window's close button */
static gboolean on_gtkpod_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) {

    if (!ok_to_close_gtkpod())
        return TRUE;

    AnjutaPluginManager *plugin_manager;
    AnjutaApp *app;
    gchar *remembered_plugins;
    gchar *session_dir;

    app = ANJUTA_APP(widget);
    plugin_manager = anjuta_shell_get_plugin_manager(ANJUTA_SHELL(app), NULL);

    /* Save remembered plugins */
    remembered_plugins = anjuta_plugin_manager_get_remembered_plugins(plugin_manager);
    g_settings_set_string(app->settings, GTKPOD_REMEMBERED_PLUGINS, remembered_plugins);
    g_free(remembered_plugins);

    session_dir = get_user_session_dir();
    anjuta_shell_session_save(ANJUTA_SHELL(app), session_dir, NULL);
    g_free(session_dir);

    anjuta_shell_notify_exit(ANJUTA_SHELL(app), NULL);

    if (!gtkpod_cleanup_quit()) {
        // Dont want to quit so avoid signalling any destroy event
        return TRUE;
    }

    return FALSE;
}
Exemple #2
0
static void on_profile_scoped(AnjutaProfileManager *profile_manager, AnjutaProfile *profile, AnjutaApp *app) {
    gchar *session_dir;
    static gboolean first_time = TRUE;

    if (strcmp(anjuta_profile_get_name(profile), USER_PROFILE_NAME) != 0)
        return;

    /* If profile scoped to "user", restore user session */
    if (system_restore_session) {
        session_dir = system_restore_session;
        system_restore_session = NULL;
    }
    else {
        session_dir = get_user_session_dir();
    }

    if (first_time) {
        first_time = FALSE;
    }
    else {
        AnjutaSession *session;
        session = anjuta_session_new(session_dir);
        anjuta_session_sync(session);
        g_object_unref(session);
    }

    /* Restore session */
    anjuta_shell_session_load(ANJUTA_SHELL (app), session_dir, NULL);
    g_free(session_dir);
}
Exemple #3
0
static void on_profile_descoped(AnjutaProfileManager *profile_manager, AnjutaProfile *profile, AnjutaApp *app) {
    gchar *session_dir;

    if (strcmp(anjuta_profile_get_name(profile), USER_PROFILE_NAME) != 0)
        return;

    /* If profile descoped from is "user", save user session */
    session_dir = get_user_session_dir();

    /* Save current session */
    anjuta_shell_session_save(ANJUTA_SHELL (app), session_dir, NULL);
    g_free(session_dir);
}
Exemple #4
0
static AnjutaShell *
anjuta_window_create_window (AnjutaShell *shell,
                          GError **error)
{
	AnjutaWindow *win = NULL;
	AnjutaApplication *app;

	/* AnjutaWindow assertions */
	g_return_val_if_fail (ANJUTA_IS_WINDOW (shell), NULL);

	app = ANJUTA_APPLICATION (gtk_window_get_application (GTK_WINDOW (shell)));
	win = anjuta_application_create_window (ANJUTA_APPLICATION (app));

	return ANJUTA_SHELL (win);
}
Exemple #5
0
static void
on_profile_descoped (AnjutaProfileManager *profile_manager,
					 AnjutaProfile *profile, AnjutaApp *app)
{
	gchar *session_dir;

	DEBUG_PRINT ("Profile descoped: %s", anjuta_profile_get_name (profile));
	if (strcmp (anjuta_profile_get_name (profile), USER_PROFILE_NAME) != 0)
		return;

	DEBUG_PRINT ("%s", "User profile descoped; Saving user session");

	/* If profile descoped from is "user", save user session */
	session_dir = USER_SESSION_PATH_NEW;

	/* Save current session */
	anjuta_shell_session_save (ANJUTA_SHELL (app), session_dir, NULL);
	g_free (session_dir);
}
Exemple #6
0
static void
on_profile_scoped (AnjutaProfileManager *profile_manager,
				   AnjutaProfile *profile, AnjutaApp *app)
{
	gchar *session_dir;
	static gboolean first_time = TRUE;

	DEBUG_PRINT ("Profile scoped: %s", anjuta_profile_get_name (profile));
	if (strcmp (anjuta_profile_get_name (profile), USER_PROFILE_NAME) != 0)
		return;

	DEBUG_PRINT ("%s", "User profile loaded; Restoring user session");

	/* If profile scoped to "user", restore user session */
	if (system_restore_session)
	{
		session_dir = system_restore_session;
		system_restore_session = NULL;
	}
	else
	{
		session_dir = USER_SESSION_PATH_NEW;
	}

	if (first_time)
	{
		first_time = FALSE;
	}
	else
	{
		/* Clear the files list since we don't want to load them later */
		AnjutaSession *session;
		session = anjuta_session_new (session_dir);
		anjuta_session_set_string_list (session, "File Loader",
										"Files", NULL);
		anjuta_session_sync (session);
		g_object_unref (session);
	}

	/* Restore session */
	anjuta_shell_session_load (ANJUTA_SHELL (app), session_dir, NULL);
	g_free (session_dir);
}
Exemple #7
0
static gboolean
on_anjuta_delete_event (AnjutaApp *app, GdkEvent *event, gpointer data)
{
	AnjutaPluginManager *plugin_manager;
	AnjutaProfileManager *profile_manager;
	AnjutaProfile *current_profile;
	AnjutaSavePrompt *save_prompt;
	gchar *remembered_plugins;

	DEBUG_PRINT ("%s", "AnjutaApp delete event");

	plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_SHELL (app), NULL);
	profile_manager = anjuta_shell_get_profile_manager (ANJUTA_SHELL (app), NULL);

	/* Save remembered plugins */
	remembered_plugins =
		anjuta_plugin_manager_get_remembered_plugins (plugin_manager);
	g_settings_set_string (app->settings,
	                       ANJUTA_REMEMBERED_PLUGINS,
	                       remembered_plugins);
	g_free (remembered_plugins);

	/* Check for unsaved data */
	save_prompt = anjuta_save_prompt_new (GTK_WINDOW (app));
	anjuta_shell_save_prompt (ANJUTA_SHELL (app), save_prompt, NULL);

	if (anjuta_save_prompt_get_items_count (save_prompt) > 0)
	{
		switch (gtk_dialog_run (GTK_DIALOG (save_prompt)))
		{
			case GTK_RESPONSE_DELETE_EVENT:
			case ANJUTA_SAVE_PROMPT_RESPONSE_CANCEL:
				gtk_widget_destroy (GTK_WIDGET (save_prompt));
				/* Do not exit now */
				return TRUE;
			case ANJUTA_SAVE_PROMPT_RESPONSE_DISCARD:
			case ANJUTA_SAVE_PROMPT_RESPONSE_SAVE_CLOSE:
				/* exit now */
				break;
		}
	}
	/* Wait for files to be really saved (asyncronous operation) */
	if (app->save_count > 0)
	{
		g_message ("Waiting for %d file(s) to be saved!", app->save_count);
		while (app->save_count > 0)
		{
			g_main_context_iteration (NULL, TRUE);
		}
	}

	/* If current active profile is "user", save current session as
	 * default session
	 */
	current_profile = anjuta_profile_manager_get_current (profile_manager);
	if (strcmp (anjuta_profile_get_name (current_profile), "user") == 0)
	{
		gchar *session_dir;
		session_dir = USER_SESSION_PATH_NEW;
		anjuta_shell_session_save (ANJUTA_SHELL (app), session_dir, NULL);
		g_free (session_dir);
	}

	anjuta_shell_notify_exit (ANJUTA_SHELL (app), NULL);

	gtk_widget_destroy (GTK_WIDGET (save_prompt));

	/* Shutdown */
	if (g_object_get_data (G_OBJECT (app), "__proper_shutdown"))
	{
		gtk_widget_hide (GTK_WIDGET (app));
		anjuta_plugin_manager_unload_all_plugins
			(anjuta_shell_get_plugin_manager (ANJUTA_SHELL (app), NULL));
	}
	return FALSE;
}
Exemple #8
0
	AnjutaPluginManager *plugin_manager;
	AnjutaProfileManager *profile_manager;
	AnjutaApp *app;
	AnjutaStatus *status;
	AnjutaProfile *profile;
	GFile *session_profile;
	gchar *remembered_plugins;
	GFile *project = NULL;
	GFile *template = NULL;
	gchar *profile_name = NULL;
	gchar *im_file = NULL;
	GError *error = NULL;

	/* Initialize application */
	app = ANJUTA_APP (anjuta_app_new ());
	status = anjuta_shell_get_status (ANJUTA_SHELL (app), NULL);
	anjuta_status_progress_add_ticks (status, 1);

	im_file = anjuta_res_get_pixmap_file (ANJUTA_PIXMAP_SPLASH_SCREEN);

	gtk_window_set_role (GTK_WINDOW (app), "anjuta-app");
	gtk_window_set_auto_startup_notification(TRUE);
	gtk_window_set_default_icon_name ("anjuta");
	gtk_window_set_auto_startup_notification(FALSE);

	if (im_file)
	{
		anjuta_status_set_splash (status, im_file, 100);
		g_free (im_file);
	}
	if (no_splash)
Exemple #9
0
void gtkpod_init(int argc, char *argv[]) {
    AnjutaPluginManager *plugin_manager;
    AnjutaProfileManager *profile_manager;
    AnjutaApp *app;
    AnjutaStatus *status;
    AnjutaProfile *profile;
    GFile *session_profile;
    GError *error = NULL;

    gchar *default_profile_file = NULL;
    gchar *user_profile_file = NULL;

    gchar *ui_file = NULL;
    gchar *remembered_plugins = NULL;
    gchar *session_dir = NULL;
    gchar *splash = NULL;

    /* Initialise important directories */
    init_directories(argv);

    register_stock_icon(GTKPOD_ICON, GTKPOD_ICON_STOCK_ID);

    /* Initialise the ui file */
    ui_file = g_build_filename(get_ui_dir(), "gtkpod.ui", NULL);
    anjuta_set_ui_file_path(ui_file);

    /* Register the application icon */
    register_stock_icon("gtkpod", GTKPOD_APP_ICON_STOCK_ID);

    /* Initialize application class instance*/
    app = ANJUTA_APP(anjuta_app_new());
    gtkpod_app = GTKPOD_APP(app);

    /* Initialise the preferences as required for the display of the splash screen */
    prefs_init(argc, argv);

    /* Show some progress as the app is initialised */
    status = anjuta_shell_get_status(ANJUTA_SHELL(app), NULL);
    anjuta_status_progress_add_ticks(status, 1);

    /* Show the splash screen if user requires */
    if (! prefs_get_int(DISABLE_SPLASH_SCREEN)) {
        splash = g_build_filename(get_icon_dir(), "gtkpod-splash.png", NULL);
        if (g_file_test(splash, G_FILE_TEST_IS_REGULAR))
            anjuta_status_set_splash(status, splash, 100);
        else {
            anjuta_status_disable_splash(status, TRUE);
        }

        g_free(splash);
    }

    /*
     * initialise gtkpod library items. Needs to be safety threaded due
     * to splash screen.
     */
    gdk_threads_enter();
    gp_init(argc, argv);
    gdk_threads_leave();

    /* Add blocking widgets from the framework */
    add_blocked_widget(app->toolbar);
    add_blocked_widget(app->view_menu);

    /* Set up shutdown signals */
    g_signal_connect(G_OBJECT(app), "delete_event", G_CALLBACK(
                    on_gtkpod_delete_event), NULL);
    g_signal_connect(G_OBJECT(app), "destroy", G_CALLBACK(on_gtkpod_destroy),
            NULL);

    plugin_manager = anjuta_shell_get_plugin_manager(ANJUTA_SHELL(app), NULL);
    profile_manager = anjuta_shell_get_profile_manager(ANJUTA_SHELL(app), NULL);

    /* Restore remembered plugins */
    remembered_plugins = g_settings_get_string(app->settings, GTKPOD_REMEMBERED_PLUGINS);
    if (remembered_plugins)
        anjuta_plugin_manager_set_remembered_plugins(plugin_manager, remembered_plugins);
    g_free(remembered_plugins);

    /* Load default profile */
    default_profile_file = get_default_profile_path();
    profile = anjuta_profile_new(USER_PROFILE_NAME, plugin_manager);
    session_profile = g_file_new_for_path(default_profile_file);
    anjuta_profile_add_plugins_from_xml(profile, session_profile, TRUE, &error);
    if (error) {
        anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message);
        g_error_free(error);
        error = NULL;
    }
    g_object_unref(session_profile);
    g_free(default_profile_file);

    /* Load user session profile */
    user_profile_file = get_user_profile_path();
    session_profile = g_file_new_for_path(user_profile_file);
    if (g_file_query_exists(session_profile, NULL)) {
        anjuta_profile_add_plugins_from_xml(profile, session_profile, FALSE, &error);
        if (error) {
            anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message);
            g_error_free(error);
            error = NULL;
        }
    }
    anjuta_profile_set_sync_file(profile, session_profile);
    g_object_unref(session_profile);
    g_free(user_profile_file);

    /* Load profile */
    anjuta_profile_manager_freeze(profile_manager);
    anjuta_profile_manager_push(profile_manager, profile, &error);
    if (error) {
        anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message);
        g_error_free(error);
        error = NULL;
    }

    /* Prepare for session save and load on profile change */
    g_signal_connect (profile_manager, "profile-scoped",
            G_CALLBACK (on_profile_scoped), app);

    anjuta_profile_manager_thaw(profile_manager, &error);

    if (error) {
        anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message);
        g_error_free(error);
        error = NULL;
    }

    g_signal_connect (profile_manager, "profile-descoped",
            G_CALLBACK (on_profile_descoped), app);

    gdk_threads_enter();
    gp_init_itdbs();
    gdk_threads_leave();

    /* Load layout.*/
    session_dir = get_user_session_dir();
    if (!g_file_test(session_dir, G_FILE_TEST_IS_DIR))
        session_dir = g_strdup(get_data_dir());

    /* Restore session */
    anjuta_shell_session_load(ANJUTA_SHELL(app), session_dir, NULL);
    g_free(session_dir);

    anjuta_status_progress_tick(status, NULL, _("Loaded Session..."));
    anjuta_status_disable_splash(status, TRUE);

    gtk_window_set_default_icon_name("gtkpod");
    gtk_window_set_auto_startup_notification(TRUE);

    gtk_window_set_role(GTK_WINDOW(app), "gtkpod-app");
    gtk_widget_show(GTK_WIDGET(app));
}
Exemple #10
0
static void
system_symbol_found (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols, gpointer user_data)
{
	update_type_list (ANJUTA_SHELL (user_data), symbols, TEXT_EDITOR_SYSTEM_TYPE_LIST);
}
Exemple #11
0
static void
project_symbol_found (IAnjutaSymbolQuery *query, IAnjutaIterable* symbols, gpointer user_data)
{
	update_type_list (ANJUTA_SHELL (user_data), symbols, TEXT_EDITOR_PROJECT_TYPE_LIST);
}
Exemple #12
0
static void
anjuta_window_instance_init (AnjutaWindow *win)
{
	GtkWidget *menubar, *about_menu;
	GtkWidget *view_menu, *hbox;
	GtkWidget *main_box;
	GtkWidget *dockbar;
	GtkAction* action;
	GList *plugins_dirs = NULL;
	GdkGeometry size_hints = {
    	100, 100, 0, 0, 100, 100, 1, 1, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  	};

	DEBUG_PRINT ("%s", "Initializing Anjuta...");

	gtk_window_set_geometry_hints (GTK_WINDOW (win), GTK_WIDGET (win),
								   &size_hints, GDK_HINT_RESIZE_INC);
	gtk_window_set_resizable (GTK_WINDOW (win), TRUE);

	/*
	 * Main box
	 */
	main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add (GTK_CONTAINER (win), main_box);
	gtk_widget_show (main_box);

	win->values = NULL;
	win->widgets = NULL;
	win->maximized = FALSE;

	/* Settings */
	win->settings = g_settings_new (PREF_SCHEMA);

	/* Status bar */
	win->status = ANJUTA_STATUS (anjuta_status_new ());
	anjuta_status_set_title_window (win->status, GTK_WIDGET (win));
	gtk_widget_show (GTK_WIDGET (win->status));
	gtk_box_pack_end (GTK_BOX (main_box),
					  GTK_WIDGET (win->status), FALSE, TRUE, 0);
	g_object_ref (G_OBJECT (win->status));
	g_object_add_weak_pointer (G_OBJECT (win->status), (gpointer)&win->status);

	/* configure dock */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_show (hbox);
	win->dock = gdl_dock_new ();
	gtk_widget_show (win->dock);
	gtk_box_pack_end(GTK_BOX (hbox), win->dock, TRUE, TRUE, 0);

	dockbar = gdl_dock_bar_new (G_OBJECT (win->dock));
	gtk_widget_show (dockbar);
	gtk_box_pack_start(GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);

	win->layout_manager = gdl_dock_layout_new (G_OBJECT (win->dock));
	g_signal_connect (win->layout_manager, "notify::dirty",
					  G_CALLBACK (on_layout_dirty_notify), win);
	g_signal_connect (gdl_dock_layout_get_master (win->layout_manager), "notify::locked",
					  G_CALLBACK (on_layout_locked_notify), win);

	/* UI engine */
	win->ui = anjuta_ui_new ();
	g_object_add_weak_pointer (G_OBJECT (win->ui), (gpointer)&win->ui);
	/* show tooltips in the statusbar */
	g_signal_connect (win->ui,
			  "connect_proxy",
			  G_CALLBACK (connect_proxy_cb),
			  win);
	g_signal_connect (win->ui,
			  "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb),
			  win);

	/* Plugin Manager */
	plugins_dirs = g_list_prepend (plugins_dirs, PACKAGE_PLUGIN_DIR);
	win->plugin_manager = anjuta_plugin_manager_new (G_OBJECT (win),
													 win->status,
													 plugins_dirs);
	win->profile_manager = anjuta_profile_manager_new (win->plugin_manager);
	g_list_free (plugins_dirs);

	/* Preferences */
	win->preferences = anjuta_preferences_new (win->plugin_manager, PREF_SCHEMA);
	g_object_add_weak_pointer (G_OBJECT (win->preferences),
							   (gpointer)&win->preferences);

	g_signal_connect (win->settings, "changed::" GDL_STYLE,
	                  G_CALLBACK (on_gdl_style_changed), win);
	on_gdl_style_changed (win->settings, GDL_STYLE, win);

	/* Register actions */
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupFile", _("File"),
										menu_entries_file,
										G_N_ELEMENTS (menu_entries_file),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupEdit", _("Edit"),
										menu_entries_edit,
										G_N_ELEMENTS (menu_entries_edit),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupView", _("View"),
										menu_entries_view,
										G_N_ELEMENTS (menu_entries_view),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_toggle_action_group_entries (win->ui, "ActionGroupToggleView",
										_("View"),
										menu_entries_toggle_view,
										G_N_ELEMENTS (menu_entries_toggle_view),
										GETTEXT_PACKAGE, TRUE, win);
	anjuta_ui_add_action_group_entries (win->ui, "ActionGroupHelp", _("Help"),
										menu_entries_help,
										G_N_ELEMENTS (menu_entries_help),
										GETTEXT_PACKAGE, TRUE, win);

	/* Merge UI */
	anjuta_ui_merge (win->ui, UI_FILE);

	/* Adding accels group */
	gtk_window_add_accel_group (GTK_WINDOW (win),
								gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (win->ui)));

	/* create main menu */
	menubar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (win->ui),
										 "/MenuMain");
	gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);

	/* create toolbar */
	win->toolbar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (win->ui),
										 "/ToolbarMain");
    if (!g_settings_get_boolean (win->settings, TOOLBAR_VISIBLE))
		gtk_widget_hide (win->toolbar);
	gtk_style_context_add_class (gtk_widget_get_style_context (win->toolbar),
	                             GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
	gtk_toolbar_set_icon_size (GTK_TOOLBAR (win->toolbar),
	                           GTK_ICON_SIZE_MENU);
	gtk_box_pack_start (GTK_BOX (main_box), win->toolbar, FALSE, FALSE, 0);
	action = gtk_ui_manager_get_action (GTK_UI_MANAGER (win->ui),
										"/MenuMain/MenuView/Toolbar");
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action),
								  g_settings_get_boolean (win->settings,
								                          TOOLBAR_VISIBLE));
	g_signal_connect (win->settings, "changed::" TOOLBAR_STYLE,
	                  G_CALLBACK (on_toolbar_style_changed), win);
	on_toolbar_style_changed (win->settings, TOOLBAR_STYLE, win);

	/* Create widgets menu */
	view_menu =
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(win->ui),
								  "/MenuMain/MenuView");
	win->view_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));

	/* Create about plugins menu */
	about_menu =
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(win->ui),
								   "/MenuMain/PlaceHolderHelpMenus/MenuHelp/"
								   "PlaceHolderHelpAbout/AboutPlugins");
	about_create_plugins_submenu (ANJUTA_SHELL (win), about_menu);

	/* Add main view */
	gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);

	/* Connect to session */
	g_signal_connect (G_OBJECT (win), "save_session",
					  G_CALLBACK (on_session_save), win);
	g_signal_connect (G_OBJECT (win), "load_session",
					  G_CALLBACK (on_session_load), win);

	/* Loading accels */
	anjuta_ui_load_accels (NULL);

	win->save_count = 0;
}
Exemple #13
0
static void
anjuta_app_instance_init (AnjutaApp *app)
{
	gint merge_id;
	GtkWidget *menubar, *about_menu;
	GtkWidget *view_menu, *hbox;
	GtkWidget *main_box;
	GtkWidget *dockbar;
	GtkAction* action;
	GList *plugins_dirs = NULL;
	gchar* style;
	GdkGeometry size_hints = {
    	100, 100, 0, 0, 100, 100, 1, 1, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  	};
	
	DEBUG_PRINT ("%s", "Initializing Anjuta...");
	
	gtk_window_set_geometry_hints (GTK_WINDOW (app), GTK_WIDGET (app),
								   &size_hints, GDK_HINT_RESIZE_INC);
	gtk_window_set_resizable (GTK_WINDOW (app), TRUE);
	
	/*
	 * Main box
	 */
	main_box = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (app), main_box);
	gtk_widget_show (main_box);
	
	app->values = NULL;
	app->widgets = NULL;
	
	/* Status bar */
	app->status = ANJUTA_STATUS (anjuta_status_new ());
	anjuta_status_set_title_window (app->status, GTK_WIDGET (app));
	gtk_widget_show (GTK_WIDGET (app->status));
	gtk_box_pack_end (GTK_BOX (main_box),
					  GTK_WIDGET (app->status), FALSE, TRUE, 0);
	g_object_ref (G_OBJECT (app->status));
	g_object_add_weak_pointer (G_OBJECT (app->status), (gpointer)&app->status);
	
	/* configure dock */
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox);
	app->dock = gdl_dock_new ();
	gtk_widget_show (app->dock);
	gtk_box_pack_end(GTK_BOX (hbox), app->dock, TRUE, TRUE, 0);
	
	dockbar = gdl_dock_bar_new (GDL_DOCK(app->dock));
	gtk_widget_show (dockbar);
	gtk_box_pack_start(GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);
	
	app->layout_manager = gdl_dock_layout_new (GDL_DOCK (app->dock));
	g_signal_connect (app->layout_manager, "notify::dirty",
					  G_CALLBACK (on_layout_dirty_notify), app);
	g_signal_connect (app->layout_manager->master, "notify::locked",
					  G_CALLBACK (on_layout_locked_notify), app);
	
	/* UI engine */
	app->ui = anjuta_ui_new ();
	g_object_add_weak_pointer (G_OBJECT (app->ui), (gpointer)&app->ui);
	/* show tooltips in the statusbar */
	g_signal_connect (app->ui,
			  "connect_proxy",
			  G_CALLBACK (connect_proxy_cb),
			  app);
	g_signal_connect (app->ui,
			  "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb),
			  app);
	
	/* Plugin Manager */
	plugins_dirs = g_list_prepend (plugins_dirs, PACKAGE_PLUGIN_DIR);
	app->plugin_manager = anjuta_plugin_manager_new (G_OBJECT (app),
													 app->status,
													 plugins_dirs);
	app->profile_manager = anjuta_profile_manager_new (app->plugin_manager);
	g_list_free (plugins_dirs);
	
	/* Preferences */
	app->preferences = anjuta_preferences_new (app->plugin_manager);
	g_object_add_weak_pointer (G_OBJECT (app->preferences),
							   (gpointer)&app->preferences);
	
	anjuta_preferences_notify_add_string (app->preferences, "anjuta.gdl.style",
	                                      on_gdl_style_changed, app, NULL);
	style = anjuta_preferences_get (app->preferences, "anjuta.gdl.style");
	
	on_gdl_style_changed (app->preferences, NULL, 
	                      style, app);
	g_free (style);
	
	/* Register actions */
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupFile", _("File"),
										menu_entries_file,
										G_N_ELEMENTS (menu_entries_file),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupEdit", _("Edit"),
										menu_entries_edit,
										G_N_ELEMENTS (menu_entries_edit),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupView", _("View"),
										menu_entries_view,
										G_N_ELEMENTS (menu_entries_view),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_toggle_action_group_entries (app->ui, "ActionGroupToggleView",
										_("View"),
										menu_entries_toggle_view,
										G_N_ELEMENTS (menu_entries_toggle_view),
										GETTEXT_PACKAGE, TRUE, app);
	anjuta_ui_add_action_group_entries (app->ui, "ActionGroupHelp", _("Help"),
										menu_entries_help,
										G_N_ELEMENTS (menu_entries_help),
										GETTEXT_PACKAGE, TRUE, app);

	/* Merge UI */
	merge_id = anjuta_ui_merge (app->ui, UI_FILE);
	
	/* Adding accels group */
	gtk_window_add_accel_group (GTK_WINDOW (app), 
								gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (app->ui)));
	
	/* create main menu */
	menubar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (app->ui),
										 "/MenuMain");
	gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);
	
	/* create toolbar */	
	app->toolbar = gtk_ui_manager_get_widget (GTK_UI_MANAGER (app->ui),
										 "/ToolbarMain");
    if (!anjuta_preferences_get_bool (app->preferences, "anjuta.toolbar.visible"))
		gtk_widget_hide (app->toolbar);
	gtk_box_pack_start (GTK_BOX (main_box), app->toolbar, FALSE, FALSE, 0);
	action = gtk_ui_manager_get_action (GTK_UI_MANAGER (app->ui),
										"/MenuMain/MenuView/Toolbar");
	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(action),
								  anjuta_preferences_get_bool_with_default (app->preferences,
																		   "anjuta.toolbar.visible",
																		   TRUE));
	anjuta_preferences_notify_add_string (app->preferences, "anjuta.toolbar.style",
								   on_toolbar_style_changed, app, NULL);
	style = anjuta_preferences_get (app->preferences, "anjuta.toolbar.style");
	on_toolbar_style_changed (app->preferences, NULL, style, app);
	g_free (style);

	/* Create widgets menu */
	view_menu = 
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(app->ui),
								  "/MenuMain/MenuView");
	app->view_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));	

	/* Disable unavailible tutorials */
	action = anjuta_ui_get_action(app->ui, "ActionGroupHelp", "ActionHelpTutorial");
	g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
	action = anjuta_ui_get_action(app->ui, "ActionGroupHelp", "ActionHelpAdvancedTutorial");
	g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
	
	/* Create about plugins menu */
	about_menu = 
		gtk_ui_manager_get_widget (GTK_UI_MANAGER(app->ui),
								   "/MenuMain/PlaceHolderHelpMenus/MenuHelp/"
								   "PlaceHolderHelpAbout/AboutPlugins");
	about_create_plugins_submenu (ANJUTA_SHELL (app), about_menu);
	
	/* Add main view */
	gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);
						
	/* Connect to session */
	g_signal_connect (G_OBJECT (app), "save_session",
					  G_CALLBACK (on_session_save), app);
	g_signal_connect (G_OBJECT (app), "load_session",
					  G_CALLBACK (on_session_load), app);
	
	/* Loading accels */
	anjuta_ui_load_accels (NULL);

	app->save_count = 0;
}