G_MODULE_EXPORT void on_menu_new_activate(GtkWidget *widget, void* user) { if (!gtk_widget_get_sensitive(GTK_WIDGET(gui->rightpane))) gui_set_hastabs_sensitive(TRUE); tabmanager_create_tab(A_NONE, NULL, NULL); }
void gui_open_file (const gchar* filename) { if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { slog(L_G_ERROR, "Failed to open file '%s': No such file or " "directory\n", filename); return; } tabmanager_create_tab (A_LOAD, filename, NULL); if (!gtk_widget_get_sensitive (GTK_WIDGET (gui->rightpane))) { gui_set_hastabs_sensitive (TRUE); } }
int main (int argc, char *argv[]) { /* set up i18n */ bindtextdomain (PACKAGE, LOCALEDIR); setlocale (LC_ALL, ""); textdomain (PACKAGE); GError* error = NULL; GOptionContext* context = g_option_context_new ("files"); g_option_context_add_main_entries (context, entries, PACKAGE); g_option_context_parse (context, &argc, &argv, &error); if (error) g_error("%s\n", error->message); /* initialize GTK */ g_thread_init (NULL); gdk_threads_init (); gtk_init (&argc, &argv); GError* ui_error = NULL; GtkBuilder* builder = gtk_builder_new (); gchar* ui = g_build_filename (DATADIR, "ui", "gummi.glade", NULL); // exit program when gummi.glade can not be located: if (!g_file_test (ui, G_FILE_TEST_EXISTS)) { printf("Could not locate Glade interface file at:\n%s\n", ui); return 0; } gtk_builder_add_from_file (builder, ui, &ui_error); if (ui_error) { g_error ("%s\n", ui_error->message); } gtk_builder_set_translation_domain (builder, PACKAGE); g_free (ui); /* Initialize logging */ slog_init (debug); slog (L_INFO, PACKAGE_NAME" version: "PACKAGE_VERSION"\n"); /* Initialize configuration */ gchar* configname = g_build_filename (g_get_user_config_dir (), "gummi", "gummi.cfg", NULL); config_init (configname); config_load (); g_free (configname); /* Initialize signals */ gummi_signals_register (); /* Initialize Classes */ gchar* snippetsname = g_build_filename (g_get_user_config_dir (), "gummi", "snippets.cfg", NULL); // why do we not load this from environment, like gui-main does? -A GuMotion* motion = motion_init (); GuIOFunc* io = iofunctions_init(); GuLatex* latex = latex_init (); GuBiblio* biblio = biblio_init (builder); GuTemplate* templ = template_init (builder); GuTabmanager* tabm = tabmanager_init (); GuProject* proj = project_init (); GuSnippets* snippets = snippets_init (snippetsname); gummi = gummi_init (motion, io, latex, biblio, templ, snippets, tabm, proj); slog (L_DEBUG, "Gummi created!\n"); g_free (snippetsname); /* Initialize GUI */ gui = gui_init (builder); slog_set_gui_parent (gui->mainwindow); slog (L_DEBUG, "GummiGui created!\n"); /* Start compile thread */ if (external_exists (config_get_value("typesetter"))) { typesetter_setup (); motion_start_compile_thread (motion); } else { infoscreengui_enable (gui->infoscreengui, "program_error"); slog (L_ERROR, "Could not locate the typesetter program\n"); } /* Install acceleration group to mainwindow */ gtk_window_add_accel_group (gui->mainwindow, snippets->accel_group); if (argc != 2) tabmanager_create_tab (A_DEFAULT, NULL, NULL); else { if (!g_file_test(argv[1], G_FILE_TEST_EXISTS)) { slog(L_ERROR, "Failed to open file '%s': No such file or " "directory\n", argv[1]); exit(1); } tabmanager_create_tab (A_LOAD, argv[1], NULL); } if (config_get_value ("autosaving")) iofunctions_start_autosave (); gui_main (builder); config_save (); config_clean_up (); return 0; }