/* 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; }
static void on_gdl_style_changed (AnjutaPreferences* prefs, const gchar* key, const gchar* pr_style, gpointer user_data) { AnjutaApp* app = ANJUTA_APP (user_data); GdlSwitcherStyle style = GDL_SWITCHER_STYLE_BOTH; if (pr_style) { if (strcasecmp (pr_style, "Text") == 0) style = GDL_SWITCHER_STYLE_TEXT; else if (strcasecmp (pr_style, "Icon") == 0) style = GDL_SWITCHER_STYLE_ICON; else if (strcasecmp (pr_style, "Both") == 0) style = GDL_SWITCHER_STYLE_BOTH; else if (strcasecmp (pr_style, "Toolbar") == 0) style = GDL_SWITCHER_STYLE_TOOLBAR; else if (strcasecmp (pr_style, "Tabs") == 0) style = GDL_SWITCHER_STYLE_TABS; DEBUG_PRINT ("Switcher style: %s", pr_style); } g_object_set (G_OBJECT(app->layout_manager->master), "switcher-style", style, NULL); }
static void on_toolbar_style_changed (AnjutaPreferences* prefs, const gchar* key, const gchar* tb_style, gpointer user_data) { AnjutaApp* app = ANJUTA_APP (user_data); if (tb_style) { if (strcasecmp (tb_style, "Default") == 0) style = -1; else if (strcasecmp (tb_style, "Both") == 0) style = GTK_TOOLBAR_BOTH; else if (strcasecmp (tb_style, "Horiz") == 0) style = GTK_TOOLBAR_BOTH_HORIZ; else if (strcasecmp (tb_style, "Icons") == 0) style = GTK_TOOLBAR_ICONS; else if (strcasecmp (tb_style, "Text") == 0) style = GTK_TOOLBAR_TEXT; DEBUG_PRINT ("Toolbar style: %s", tb_style); } if (style != -1) { gtk_toolbar_set_style (GTK_TOOLBAR (app->toolbar), style); } else { gtk_toolbar_unset_style (GTK_TOOLBAR (app->toolbar)); } }
static void anjuta_app_dispose (GObject *widget) { AnjutaApp *app; g_return_if_fail (ANJUTA_IS_APP (widget)); app = ANJUTA_APP (widget); if (app->widgets) { if (g_hash_table_size (app->widgets) > 0) { /* g_warning ("Some widgets are still inside shell (%d widgets), they are:", g_hash_table_size (app->widgets)); g_hash_table_foreach (app->widgets, (GHFunc)puts, NULL); */ } g_hash_table_destroy (app->widgets); app->widgets = NULL; } if (app->values) { if (g_hash_table_size (app->values) > 0) { /* g_warning ("Some Values are still left in shell (%d Values), they are:", g_hash_table_size (app->values)); g_hash_table_foreach (app->values, (GHFunc)puts, NULL); */ } g_hash_table_destroy (app->values); app->values = NULL; } if (app->layout_manager) { g_object_unref (app->layout_manager); app->layout_manager = NULL; } if (app->profile_manager) { g_object_unref (G_OBJECT (app->profile_manager)); app->profile_manager = NULL; } if (app->plugin_manager) { g_object_unref (G_OBJECT (app->plugin_manager)); app->plugin_manager = NULL; } if (app->status) { g_object_unref (G_OBJECT (app->status)); app->status = NULL; } G_OBJECT_CLASS (parent_class)->dispose (widget); }
static void anjuta_app_finalize (GObject *widget) { AnjutaApp *app; g_return_if_fail (ANJUTA_IS_APP (widget)); app = ANJUTA_APP (widget); gtk_widget_destroy (GTK_WIDGET (app->ui)); gtk_widget_destroy (GTK_WIDGET (app->preferences)); G_OBJECT_CLASS (parent_class)->finalize (widget); }
static void on_layout_dirty_notify (GObject *object, GParamSpec *pspec, gpointer user_data) { if (!strcmp (pspec->name, "dirty")) { gboolean dirty; g_object_get (object, "dirty", &dirty, NULL); if (dirty) { /* Update UI toggle buttons */ g_hash_table_foreach (ANJUTA_APP (user_data)->widgets, on_update_widget_view_menuitem, NULL); } } }
{ 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); }
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)); }