void conterm_load_config(void) { gchar *configfile = g_build_filename(geany_data->app->configdir, "geany.conf", NULL); GKeyFile *config = g_key_file_new(); gchar *tmp_string; g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); pref_vte_blinken = utils_get_setting_boolean(config, "VTE", "cursor_blinks", FALSE); pref_vte_emulation = utils_get_setting_string(config, "VTE", "emulation", "xterm"); pref_vte_font = utils_get_setting_string(config, "VTE", "font", "Monospace 10"); pref_vte_scrollback = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500); tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff"); #if !GTK_CHECK_VERSION(3, 14, 0) gdk_color_parse(tmp_string, &pref_vte_colour_fore); #else gdk_rgba_parse(&pref_vte_colour_fore, tmp_string); #endif g_free(tmp_string); tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000"); #if !GTK_CHECK_VERSION(3, 14, 0) gdk_color_parse(tmp_string, &pref_vte_colour_back); #else gdk_rgba_parse(&pref_vte_colour_back, tmp_string); #endif g_free(tmp_string); g_key_file_free(config); g_free(configfile); }
void plugin_init(GeanyData *data) { home = g_getenv("HOME"); if (!home) { home = g_get_home_dir(); } conf = g_build_path(G_DIR_SEPARATOR_S, geany_data->app->configdir, "plugins", "quick-opener.conf", NULL); config = g_key_file_new(); g_key_file_load_from_file(config, conf, G_KEY_FILE_NONE, NULL); include_path = utils_get_setting_boolean(config, "main", "include-path", include_path); pathRegexSetting.text = utils_get_setting_string(config, "main", "path-regex", pathRegexSetting.DEFAULT); nameRegexSetting.text = utils_get_setting_string(config, "main", "name-regex", nameRegexSetting.DEFAULT); opener_path = utils_get_setting_string(config, "main", "path", home); setup_regex(); GeanyKeyGroup *key_group; key_group = plugin_set_key_group(geany_plugin, "quick_open_keyboard_shortcut", COUNT_KB, NULL); keybindings_set_item(key_group, KB_QUICK_OPEN_PROJECT, quick_open_project_keyboard_shortcut, 0, 0, "quick_open_project_keyboard_shortcut", _("Quick Open Project Files..."), NULL); keybindings_set_item(key_group, KB_QUICK_OPEN, quick_open_keyboard_shortcut, 0, 0, "quick_open_keyboard_shortcut", _("Quick Open..."), NULL); quick_open_project_menu = gtk_menu_item_new_with_mnemonic("Quick Open Project Files..."); gtk_widget_show(quick_open_project_menu); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), quick_open_project_menu); g_signal_connect(quick_open_project_menu, "activate", G_CALLBACK(quick_open_project_menu_callback), NULL); quick_open_menu = gtk_menu_item_new_with_mnemonic("Quick Open..."); gtk_widget_show(quick_open_menu); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), quick_open_menu); g_signal_connect(quick_open_menu, "activate", G_CALLBACK(quick_open_menu_callback), NULL); }
/* load individual file details. return TRUE if data there, FALSE if there isn't */ static gboolean LoadIndividualSetting(GKeyFile *gkf,gint iNumber,gchar *Filename) { gchar *pcKey=NULL; gchar *pcTemp; gchar *pcTemp2; gint l; FileData *fd=NULL; /* if loading from local file then no fiilename in file and no number in key*/ if(iNumber==-1) { /* get structure to hold filedetails */ fd=GetFileData(Filename); /* create key */ pcKey=g_strdup("A"); } /* if loading from central file then need to extract filename from A key */ else { pcKey=g_strdup_printf("A%d",iNumber); /* get filename */ pcTemp=(gchar*)(utils_get_setting_string(gkf,"FileData",pcKey,NULL)); /* if null then have reached end of files */ if(pcTemp==NULL) { g_free(pcKey); return FALSE; } fd=GetFileData(pcTemp); g_free(pcTemp); } /* get folding data */ pcKey[0]='B'; if(bRememberFolds==TRUE) fd->pcFolding=(gchar*)(utils_get_setting_string(gkf,"FileData",pcKey,NULL)); else fd->pcFolding=NULL; /* load last saved time */ pcKey[0]='C'; fd->LastChangedTime=utils_get_setting_integer(gkf,"FileData",pcKey,-1); /* free used memory */ g_free(pcTemp); g_free(pcKey); return TRUE; }
void plugin_init(GeanyData *data) { GeanyKeyGroup *key_group; GKeyFile *config = g_key_file_new(); gchar *default_lang; default_lang = sc_speller_get_default_lang(); sc_info = g_new0(SpellCheck, 1); sc_info->config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "spellcheck", G_DIR_SEPARATOR_S, "spellcheck.conf", NULL); g_key_file_load_from_file(config, sc_info->config_file, G_KEY_FILE_NONE, NULL); sc_info->default_language = utils_get_setting_string(config, "spellcheck", "language", default_lang); sc_info->check_while_typing = utils_get_setting_boolean(config, "spellcheck", "check_while_typing", FALSE); sc_info->check_on_document_open = utils_get_setting_boolean(config, "spellcheck", "check_on_document_open", FALSE); sc_info->show_toolbar_item = utils_get_setting_boolean(config, "spellcheck", "show_toolbar_item", TRUE); sc_info->show_editor_menu_item = utils_get_setting_boolean(config, "spellcheck", "show_editor_menu_item", TRUE); sc_info->show_editor_menu_item_sub_menu = utils_get_setting_boolean(config, "spellcheck", "show_editor_menu_item_sub_menu", TRUE); sc_info->dictionary_dir = utils_get_setting_string(config, "spellcheck", "dictionary_dir", NULL); sc_info->use_msgwin = utils_get_setting_boolean(config, "spellcheck", "use_msgwin", FALSE); g_key_file_free(config); g_free(default_lang); sc_info->menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_SPELL_CHECK, NULL); ui_add_document_sensitive(sc_info->menu_item); sc_gui_update_toolbar(); sc_gui_init(); sc_speller_init(); sc_gui_update_menu(); gtk_widget_show_all(sc_info->menu_item); /* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "spellcheck", KB_COUNT, NULL); keybindings_set_item(key_group, KB_SPELL_CHECK, sc_gui_kb_run_activate_cb, 0, 0, "spell_check", _("Run Spell Check"), sc_info->submenu_item_default); keybindings_set_item(key_group, KB_SPELL_TOOGLE_TYPING, sc_gui_kb_toggle_typing_activate_cb, 0, 0, "spell_toggle_typing", _("Toggle Check While Typing"), NULL); }
/* Reads the given filename and creates a new project with the data found in the file. * At this point there should not be an already opened project in Geany otherwise it will just * return. * The filename is expected in the locale encoding. */ static gboolean load_config(const gchar *filename) { GKeyFile *config; GeanyProject *p; GSList *node; /* there should not be an open project */ g_return_val_if_fail(app->project == NULL && filename != NULL, FALSE); config = g_key_file_new(); if (! g_key_file_load_from_file(config, filename, G_KEY_FILE_NONE, NULL)) { g_key_file_free(config); return FALSE; } p = create_project(); foreach_slist(node, stash_groups) stash_group_load_from_key_file(node->data, config); p->name = utils_get_setting_string(config, "project", "name", GEANY_STRING_UNTITLED); p->description = utils_get_setting_string(config, "project", "description", ""); p->file_name = utils_get_utf8_from_locale(filename); p->base_path = utils_get_setting_string(config, "project", "base_path", ""); p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL); p->long_line_behaviour = utils_get_setting_integer(config, "long line marker", "long_line_behaviour", 1 /* follow global */); p->long_line_column = utils_get_setting_integer(config, "long line marker", "long_line_column", editor_prefs.long_line_column); apply_editor_prefs(); build_load_menu(config, GEANY_BCS_PROJ, (gpointer)p); if (project_prefs.project_session) { /* save current (non-project) session (it could has been changed since program startup) */ configuration_save_default_session(); /* now close all open files */ document_close_all(); /* read session files so they can be opened with configuration_open_files() */ configuration_load_session_files(config, FALSE); ui_focus_current_document(); } g_signal_emit_by_name(geany_object, "project-open", config); g_key_file_free(config); update_ui(); return TRUE; }
void project_load_prefs(GKeyFile *config) { if (cl_options.load_session) { g_return_if_fail(project_prefs.session_file == NULL); project_prefs.session_file = utils_get_setting_string(config, "project", "session_file", ""); } local_prefs.project_file_path = utils_get_setting_string(config, "project", "project_file_path", NULL); if (local_prefs.project_file_path == NULL) { local_prefs.project_file_path = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, PROJECT_DIR, NULL); } }
void plugin_init(GeanyData *data) { GKeyFile *config = g_key_file_new(); GeanyKeyGroup *key_group; ao_info = g_new0(AddonsInfo, 1); ao_info->config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "addons", G_DIR_SEPARATOR_S, "addons.conf", NULL); g_key_file_load_from_file(config, ao_info->config_file, G_KEY_FILE_NONE, NULL); ao_info->enable_doclist = utils_get_setting_boolean(config, "addons", "show_toolbar_doclist_item", TRUE); ao_info->doclist_sort_mode = utils_get_setting_integer(config, "addons", "doclist_sort_mode", DOCLIST_SORT_BY_OCCURRENCE); ao_info->enable_openuri = utils_get_setting_boolean(config, "addons", "enable_openuri", FALSE); ao_info->enable_tasks = utils_get_setting_boolean(config, "addons", "enable_tasks", TRUE); ao_info->tasks_scan_all_documents = utils_get_setting_boolean(config, "addons", "tasks_scan_all_documents", FALSE); ao_info->tasks_token_list = utils_get_setting_string(config, "addons", "tasks_token_list", "TODO;FIXME"); ao_info->enable_systray = utils_get_setting_boolean(config, "addons", "enable_systray", FALSE); ao_info->enable_bookmarklist = utils_get_setting_boolean(config, "addons", "enable_bookmarklist", FALSE); ao_info->enable_markword = utils_get_setting_boolean(config, "addons", "enable_markword", FALSE); ao_info->strip_trailing_blank_lines = utils_get_setting_boolean(config, "addons", "strip_trailing_blank_lines", FALSE); ao_info->enable_xmltagging = utils_get_setting_boolean(config, "addons", "enable_xmltagging", FALSE); plugin_module_make_resident(geany_plugin); ao_info->doclist = ao_doc_list_new(ao_info->enable_doclist, ao_info->doclist_sort_mode); ao_info->openuri = ao_open_uri_new(ao_info->enable_openuri); ao_info->systray = ao_systray_new(ao_info->enable_systray); ao_info->bookmarklist = ao_bookmark_list_new(ao_info->enable_bookmarklist); ao_info->markword = ao_mark_word_new(ao_info->enable_markword); ao_info->tasks = ao_tasks_new(ao_info->enable_tasks, ao_info->tasks_token_list, ao_info->tasks_scan_all_documents); ao_blanklines_set_enable(ao_info->strip_trailing_blank_lines); /* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "addons", KB_COUNT, NULL); keybindings_set_item(key_group, KB_FOCUS_BOOKMARK_LIST, kb_bmlist_activate, 0, 0, "focus_bookmark_list", _("Focus Bookmark List"), NULL); keybindings_set_item(key_group, KB_FOCUS_TASKS, kb_tasks_activate, 0, 0, "focus_tasks", _("Focus Tasks List"), NULL); keybindings_set_item(key_group, KB_UPDATE_TASKS, kb_tasks_update, 0, 0, "update_tasks", _("Update Tasks List"), NULL); keybindings_set_item(key_group, KB_XMLTAGGING, kb_ao_xmltagging, 0, 0, "xml_tagging", _("Run XML tagging"), NULL); }
static void on_comboboxType_changed(GtkComboBox * combobox, G_GNUC_UNUSED gpointer user_data) { gchar *from, *to; GtkWidget *cmd0 = ui_lookup_widget(GTK_WIDGET(combobox), "entryCommand0"); GtkWidget *cmd1 = ui_lookup_widget(GTK_WIDGET(combobox), "entryCommand1"); GtkWidget *intern = ui_lookup_widget(GTK_WIDGET(combobox), "cbIntern"); gchar *cmd0_txt = (gchar *) gtk_entry_get_text(GTK_ENTRY(cmd0)); gchar *cmd1_txt = (gchar *) gtk_entry_get_text(GTK_ENTRY(cmd1)); gboolean intern_b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(intern)); GKeyFile *config = (GKeyFile *) g_object_get_data(G_OBJECT(combobox), "config"); from = g_object_get_data(G_OBJECT(combobox), "current"); to = gtk_combo_box_get_active_text(combobox); if (from != NULL) { if (! EMPTY(cmd0_txt)) g_key_file_set_string(config, from, "command0", cmd0_txt); else g_key_file_remove_key(config, from, "command0", NULL); if (! EMPTY(cmd1_txt)) g_key_file_set_string(config, from, "command1", cmd1_txt); else g_key_file_remove_key(config, from, "command1", NULL); g_key_file_set_boolean(config, from, "internal", intern_b); g_free(from); } g_object_set_data(G_OBJECT(combobox), "current", g_strdup(to)); cmd0_txt = utils_get_setting_string(config, to, "command0", ""); cmd1_txt = utils_get_setting_string(config, to, "command1", ""); intern_b = utils_get_setting_boolean(config, to, "internal", FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(intern), intern_b); gtk_entry_set_text(GTK_ENTRY(cmd0), cmd0_txt); gtk_entry_set_text(GTK_ENTRY(cmd1), cmd1_txt); }
void plugin_init(GeanyData *data) { GKeyFile *config = g_key_file_new(); gchar *tmp; config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "saveactions", G_DIR_SEPARATOR_S, "saveactions.conf", NULL); g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); enable_autosave = utils_get_setting_boolean( config, "saveactions", "enable_autosave", FALSE); enable_autosave_losing_focus = utils_get_setting_boolean( config, "saveactions", "enable_autosave_losing_focus", FALSE); enable_instantsave = utils_get_setting_boolean( config, "saveactions", "enable_instantsave", FALSE); enable_backupcopy = utils_get_setting_boolean( config, "saveactions", "enable_backupcopy", FALSE); instantsave_default_ft = utils_get_setting_string(config, "instantsave", "default_ft", filetypes[GEANY_FILETYPES_NONE]->name); autosave_src_id = 0; /* mark as invalid */ autosave_interval = utils_get_setting_integer(config, "autosave", "interval", 300); autosave_print_msg = utils_get_setting_boolean(config, "autosave", "print_messages", FALSE); autosave_save_all = utils_get_setting_boolean(config, "autosave", "save_all", FALSE); if (enable_autosave) autosave_set_timeout(); backupcopy_dir_levels = utils_get_setting_integer(config, "backupcopy", "dir_levels", 0); backupcopy_time_fmt = utils_get_setting_string( config, "backupcopy", "time_fmt", "%Y-%m-%d-%H-%M-%S"); tmp = utils_get_setting_string(config, "backupcopy", "backup_dir", g_get_tmp_dir()); backupcopy_set_backup_dir(tmp); g_key_file_free(config); g_free(tmp); }
static void load_scope_prefs(GKeyFile *config) { guint i; MarkerStyle *style = pref_marker_styles; stash_group_load_from_key_file(scope_group, config); stash_group_load_from_key_file(terminal_group, config); for (i = 0; i < MARKER_COUNT; i++, style++) { gchar *tmp_string; stash_group_load_from_key_file(marker_group[i], config); tmp_string = utils_get_setting_string(config, style->name, "fore", style->default_fore); style->fore = utils_parse_sci_color(tmp_string); g_free(tmp_string); tmp_string = utils_get_setting_string(config, style->name, "back", style->default_back); style->back = utils_parse_sci_color(tmp_string); g_free(tmp_string); } }
static void load_settings(void) { GKeyFile *config = g_key_file_new(); config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geniuspaste", G_DIR_SEPARATOR_S, "geniuspaste.conf", NULL); g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); website_selected = utils_get_setting_integer(config, "geniuspaste", "website", PASTEBIN_GEANY_ORG); check_button_is_checked = utils_get_setting_boolean(config, "geniuspaste", "open_browser", FALSE); author_name = utils_get_setting_string(config, "geniuspaste", "author_name", USERNAME); g_key_file_free(config); }
static gboolean recent_program_load(GKeyFile *config, const char *section) { gchar *name = utils_get_setting_string(config, section, "name", NULL); gint id = utils_get_setting_integer(config, section, "id", 0); gboolean valid = FALSE; if (name && id > 0 && id <= RECENT_COUNT && (recent_bitmap & (1 << id)) == 0) { scp_tree_store_append_with_values(recent_programs, NULL, NULL, PROGRAM_NAME, name, PROGRAM_ID, id, -1); recent_bitmap |= 1 << id; valid = TRUE; } g_free(name); return valid; }
static gboolean recent_program_load(GKeyFile *config, const char *section) { gchar *name = utils_get_setting_string(config, section, "name", NULL); gint id = utils_get_setting_integer(config, section, "id", 0); if (name && *name && id > 0 && (recent_bitmap & (1 << id)) == 0 && recent_programs->len < RECENT_COUNT) { RecentProgram *recent = (RecentProgram *) array_append(recent_programs); recent->name = name; recent->id = id; recent_bitmap |= 1 << id; return TRUE; } g_free(name); return FALSE; }
/* load settings (preferences, file data, and macro data) */ static void LoadSettings(void) { gint i; gchar *config_file=NULL; gchar *config_dir=NULL; GKeyFile *config=NULL; /* Make config_dir hold directory name of settings file */ config_dir=g_build_filename(geany->app->configdir,"plugins","Geany_Numbered_Bookmarks",NULL); /* ensure directory exists */ g_mkdir_with_parents(config_dir,0755); /* make config_file hold name of settings file */ config_file=g_build_filename(config_dir,"settings.conf",NULL); /* either load settings file, or create one from default */ config=g_key_file_new(); if(!g_key_file_load_from_file(config,config_file, G_KEY_FILE_KEEP_COMMENTS,NULL)) g_key_file_load_from_data(config,default_config,sizeof(default_config), G_KEY_FILE_KEEP_COMMENTS,NULL); /* extract settings */ bCenterWhenGotoBookmark=utils_get_setting_boolean(config,"Settings", "Center_When_Goto_Bookmark",FALSE); bRememberFolds=utils_get_setting_boolean(config,"Settings","Remember_Folds",FALSE); PositionInLine=utils_get_setting_integer(config,"Settings","Position_In_Line",0); WhereToSaveFileDetails=utils_get_setting_integer(config,"Settings", "Where_To_Save_File_Details",0); bRememberBookmarks=utils_get_setting_boolean(config,"Settings","Remember_Bookmarks",FALSE); FileDetailsSuffix=utils_get_setting_string(config,"Settings","File_Details_Suffix", ".gnbs.conf"); /* extract data about files */ i=0; while(LoadIndividualSetting(config,i,NULL)) i++; /* free memory */ g_free(config_dir); g_free(config_file); g_key_file_free(config); }
void ao_enclose_words_init (gchar *config_file_name, GeanyKeyGroup *key_group) { GKeyFile *config = g_key_file_new(); gchar key_name[] = "Enclose_x"; gint i; config_file = g_strdup (config_file_name); g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, NULL); for (i = 0; i < 8; i++) { key_name [8] = (gchar) (i + '0'); enclose_chars [i] = utils_get_setting_string (config, "addons", key_name, " "); key_name [8] = (gchar) ((i + 1) + '0'); keybindings_set_item (key_group, i+4, (GeanyKeyCallback) enclose_text_action, 0, 0, key_name, key_name, NULL); } plugin_signal_connect(geany_plugin, G_OBJECT(geany->main_widgets->window), "key-press-event", FALSE, G_CALLBACK(on_key_press), NULL); }
/* Called by Geany to initialize the plugin */ void plugin_init(G_GNUC_UNUSED GeanyData *data) { GtkWidget *menu_lipsum = NULL; GKeyFile *config = g_key_file_new(); gchar *config_file = NULL; GeanyKeyGroup *key_group; main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanylipsum", G_DIR_SEPARATOR_S, "lipsum.conf", NULL); /* Initialising options from config file if there is any*/ g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); lipsum = utils_get_setting_string(config, "snippets", "lipsumtext", default_loremipsum); g_key_file_free(config); g_free(config_file); /* Building menu entry */ menu_lipsum = gtk_image_menu_item_new_with_mnemonic(_("_Lipsum")); gtk_widget_set_tooltip_text(menu_lipsum, _("Include Pseudotext to your code")); gtk_widget_show(menu_lipsum); g_signal_connect((gpointer) menu_lipsum, "activate", G_CALLBACK(lipsum_activated), NULL); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_lipsum); ui_add_document_sensitive(menu_lipsum); main_menu_item = menu_lipsum; /* init keybindings */ key_group = plugin_set_key_group(geany_plugin, "geanylipsum", COUNT_KB, NULL); keybindings_set_item(key_group, LIPSUM_KB_INSERT, kblipsum_insert, 0, 0, "insert_lipsum", _("Insert Lipsum text"), menu_lipsum); }
/* * init debug related GUI (watch tree view) * arguments: */ void debug_init() { /* create watch page */ wtree = wtree_init(on_watch_expanded_callback, on_watch_dragged_callback, on_watch_key_pressed_callback, on_watch_changed, on_watch_button_pressed_callback); wmodel = gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)); wstore = GTK_TREE_STORE(wmodel); tab_watch = gtk_scrolled_window_new( gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(wtree)), gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(wtree)) ); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_watch), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(tab_watch), wtree); /* create autos page */ atree = atree_init(on_watch_expanded_callback, on_watch_button_pressed_callback); tab_autos = gtk_scrolled_window_new( gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(atree)), gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(atree)) ); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_autos), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(tab_autos), atree); /* create stack trace page */ stree = stree_init(editor_open_position, on_select_frame); tab_call_stack = gtk_scrolled_window_new( gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(stree )), gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(stree )) ); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_call_stack), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(tab_call_stack), stree); /* create debug terminal page */ terminal = vte_terminal_new(); /* create PTY */ openpty(&pty_master, &pty_slave, NULL, NULL, NULL); grantpt(pty_master); unlockpt(pty_master); vte_terminal_set_pty(VTE_TERMINAL(terminal), pty_master); GtkWidget *scrollbar = gtk_vscrollbar_new(GTK_ADJUSTMENT(VTE_TERMINAL(terminal)->adjustment)); GTK_WIDGET_UNSET_FLAGS(scrollbar, GTK_CAN_FOCUS); tab_terminal = gtk_frame_new(NULL); gtk_frame_set_shadow_type (GTK_FRAME(tab_terminal), GTK_SHADOW_NONE); GtkWidget *hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(tab_terminal), hbox); gtk_box_pack_start(GTK_BOX(hbox), terminal, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0); /* set the default widget size first to prevent VTE expanding too much, * sometimes causing the hscrollbar to be too big or out of view. */ gtk_widget_set_size_request(GTK_WIDGET(terminal), 10, 10); vte_terminal_set_size(VTE_TERMINAL(terminal), 30, 1); /* set terminal font. */ GKeyFile *config = g_key_file_new(); gchar *configfile = g_strconcat(geany_data->app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); gchar *font = utils_get_setting_string(config, "VTE", "font", "Monospace 10"); vte_terminal_set_font_from_string (VTE_TERMINAL(terminal), font); /* debug messages page */ tab_messages = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_messages), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(tab_messages)); vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(tab_messages)); debugger_messages_textview = gtk_text_view_new(); gtk_text_view_set_editable (GTK_TEXT_VIEW (debugger_messages_textview), FALSE); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tab_messages), debugger_messages_textview); /* create tex tags */ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(debugger_messages_textview)); gtk_text_buffer_create_tag(buffer, "black", "foreground", "#000000", NULL); gtk_text_buffer_create_tag(buffer, "grey", "foreground", "#AAAAAA", NULL); gtk_text_buffer_create_tag(buffer, "red", "foreground", "#FF0000", NULL); gtk_text_buffer_create_tag(buffer, "green", "foreground", "#00FF00", NULL); gtk_text_buffer_create_tag(buffer, "blue", "foreground", "#0000FF", NULL); gtk_text_buffer_create_tag(buffer, "yellow", "foreground", "#FFFF00", NULL); gtk_text_buffer_create_tag(buffer, "brown", "foreground", "#BB8915", NULL); gtk_text_buffer_create_tag(buffer, "rose", "foreground", "#BA92B7", NULL); }
/* Called by Geany to initialize the plugin */ void plugin_init(G_GNUC_UNUSED GeanyData *data) { GtkWidget *menu_lipsum = NULL; GKeyFile *config = g_key_file_new(); gchar *config_file = NULL; gchar *config_file_old = NULL; gchar *config_dir = NULL; gchar *config_dir_old = NULL; GeanyKeyGroup *key_group; config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanylipsum", G_DIR_SEPARATOR_S, "lipsum.conf", NULL); #ifndef G_OS_WIN32 /* We try only to move if we are on not Windows platform */ config_dir_old = g_build_filename(geany->app->configdir, "plugins", "geanylipsum", NULL); config_file_old = g_build_filename(config_dir_old, "lipsum.conf", NULL); config_dir = g_build_filename(geany->app->configdir, "plugins", "lipsum", NULL); if (g_file_test(config_file_old, G_FILE_TEST_EXISTS)) { if (dialogs_show_question( _("Renamed plugin detected!\n" "\n" "As you may have already noticed, GeanyLipsum has been " "renamed to just Lipsum. \n" "Geany is able to migrate your old plugin configuration by " "moving the old configuration file to new location.\n" "Warning: This will not include your keybindings.\n" "Move now?"))) { if (g_rename(config_dir_old, config_dir) == 0) { dialogs_show_msgbox(GTK_MESSAGE_INFO, _("Your configuration directory has been " "successfully moved from \"%s\" to \"%s\"."), config_dir_old, config_dir); } else { /* If there was an error on migrating we need * to load from original one. * When saving new configuration it will go to * new folder so migration should * be implicit. */ g_free(config_file); config_file = g_strdup(config_file_old); dialogs_show_msgbox( GTK_MESSAGE_WARNING, _("Your old configuration directory \"%s\" could " "not be moved to \"%s\" (%s). " "Please manually move the directory to the new location."), config_dir_old, config_dir, g_strerror(errno)); } } } g_free(config_dir_old); g_free(config_dir); g_free(config_file_old); #endif /* Initialising options from config file if there is any*/ g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); lipsum = utils_get_setting_string(config, "snippets", "lipsumtext", default_loremipsum); g_key_file_free(config); g_free(config_file); /* Building menu entry */ menu_lipsum = gtk_image_menu_item_new_with_mnemonic(_("_Lipsum...")); gtk_widget_set_tooltip_text(menu_lipsum, _("Include Pseudotext to your code")); gtk_widget_show(menu_lipsum); g_signal_connect((gpointer) menu_lipsum, "activate", G_CALLBACK(lipsum_activated), NULL); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_lipsum); ui_add_document_sensitive(menu_lipsum); main_menu_item = menu_lipsum; /* init keybindings */ key_group = plugin_set_key_group(geany_plugin, "lipsum", COUNT_KB, NULL); keybindings_set_item(key_group, LIPSUM_KB_INSERT, kblipsum_insert, 0, 0, "insert_lipsum", _("Insert Lipsum text"), menu_lipsum); }
void prefs_init(void) { guint i; MarkerStyle *style = pref_marker_styles; StashGroup *group; char *configdir = g_build_filename(geany->app->configdir, "plugins", "scope", NULL); char *configfile = prefs_file_name(); GKeyFile *config = g_key_file_new(); gchar *tmp_string; group = stash_group_new("scope"); stash_group_add_string(group, &pref_gdb_executable, "gdb_executable", "gdb"); stash_group_add_boolean(group, &pref_gdb_async_mode, "gdb_async_mode", FALSE); stash_group_add_integer(group, &pref_gdb_buffer_length, "gdb_buffer_length", 16383); stash_group_add_integer(group, &pref_gdb_wait_death, "gdb_wait_death", 20); #ifndef G_OS_UNIX stash_group_add_integer(group, &pref_gdb_send_interval, "gdb_send_interval", 5); stash_group_add_boolean(group, &pref_async_break_bugs, "async_break_bugs", TRUE); #endif stash_group_add_boolean(group, &pref_auto_view_source, "auto_view_source", FALSE); stash_group_add_boolean(group, &pref_keep_exec_point, "keep_exec_point", FALSE); stash_group_add_integer(group, &pref_visual_beep_length, "visual_beep_length", 25); #ifdef G_OS_UNIX stash_group_add_boolean(group, &pref_debug_console_vte, "debug_console_vte", TRUE); #endif stash_group_add_integer(group, &pref_sci_marker_1st, "sci_marker_first", 17); stash_group_add_integer(group, &pref_sci_caret_policy, "sci_caret_policy", CARET_SLOP | CARET_JUMPS | CARET_EVEN); stash_group_add_integer(group, &pref_sci_caret_slop, "sci_caret_slop", 3); stash_group_add_boolean(group, &pref_unmark_current_line, "unmark_current_line", FALSE); stash_group_add_boolean(group, &pref_scope_goto_cursor, "scope_run_to_cursor", FALSE); stash_group_add_boolean(group, &pref_seek_with_navqueue, "seek_with_navqueue", FALSE); stash_group_add_integer(group, &pref_panel_tab_pos, "panel_tab_pos", GTK_POS_TOP); stash_group_add_integer(group, &pref_show_recent_items, "show_recent_items", 10); stash_group_add_integer(group, &pref_show_toolbar_items, "show_toolbar_items", 0xFF); stash_group_add_integer(group, &pref_tooltips_fail_action, "tooltips_fail_action", 0); stash_group_add_integer(group, &pref_tooltips_send_delay, "tooltips_send_delay", 25); stash_group_add_integer(group, &pref_tooltips_length, "tooltips_length", 2048); stash_group_add_integer(group, &pref_memory_bytes_per_line, "memory_line_bytes", 16); stash_group_add_string(group, &pref_memory_font, "memory_font", ""); scope_group = group; config_item = ui_add_config_file_menu_item(configfile, NULL, NULL); plugin_signal_connect(geany_plugin, NULL, "document-save", FALSE, G_CALLBACK(on_document_save), NULL); group = stash_group_new("terminal"); #ifdef G_OS_UNIX stash_group_add_boolean(group, &pref_terminal_save_pos, "save_pos", TRUE); stash_group_add_boolean(group, &pref_terminal_padding, "padding", TRUE); stash_group_add_integer(group, &pref_terminal_window_x, "window_x", 70); stash_group_add_integer(group, &pref_terminal_window_y, "window_y", 50); stash_group_add_integer(group, &pref_terminal_width, "width", 640); stash_group_add_integer(group, &pref_terminal_height, "height", 480); #endif /* G_OS_UNIX */ terminal_group = group; for (i = 0; i < MARKER_COUNT; i++, style++) { group = stash_group_new(style->name); stash_group_add_integer(group, &style->mark, "mark", style->default_mark); stash_group_add_integer(group, &style->alpha, "alpha", style->default_alpha); marker_group[i] = group; } g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); load_scope_prefs(config); pref_sci_marker_first = pref_sci_marker_1st; prefs_configure(); program_load_config(config); if (pref_panel_tab_pos == GTK_POS_LEFT || pref_panel_tab_pos == GTK_POS_RIGHT) { gtk_label_set_label(GTK_LABEL(get_widget("program_terminal_label")), _("Program")); gtk_label_set_label(GTK_LABEL(get_widget("break_view_label")), _("Breaks")); gtk_label_set_label(GTK_LABEL(get_widget("debug_console_label")), _("Console")); } if (!g_file_test(configfile, G_FILE_TEST_IS_REGULAR)) { gint error = utils_mkdir(configdir, TRUE); if (error) msgwin_status_add(_("Scope: %s: %s."), configdir, g_strerror(error)); else { save_scope_prefs(config); if (utils_key_file_write_to_file(config, configfile)) msgwin_status_add(_("Scope: created configuration file.")); } } g_key_file_free(config); g_free(configfile); g_free(configdir); configfile = g_build_filename(geany_data->app->configdir, "geany.conf", NULL); config = g_key_file_new(); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); pref_vte_blinken = utils_get_setting_boolean(config, "VTE", "cursor_blinks", FALSE); pref_vte_emulation = utils_get_setting_string(config, "VTE", "emulation", "xterm"); pref_vte_font = utils_get_setting_string(config, "VTE", "font", "Monospace 10"); pref_vte_scrollback = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500); tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff"); gdk_color_parse(tmp_string, &pref_vte_colour_fore); g_free(tmp_string); tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000"); gdk_color_parse(tmp_string, &pref_vte_colour_back); g_free(tmp_string); g_key_file_free(config); g_free(configfile); }
void plugin_init(GeanyData *data) { conf = g_build_path(G_DIR_SEPARATOR_S, geany_data->app->configdir, "plugins", "quick-find.conf", NULL); config = g_key_file_new(); g_key_file_load_from_file(config, conf, G_KEY_FILE_NONE, NULL); executable = utils_get_setting_string(config, "main", "executable", DEFAULT_EXECUTABLE); trim_file = g_regex_new(g_strconcat("^.*", G_DIR_SEPARATOR_S, NULL), G_REGEX_OPTIMIZE | G_REGEX_CASELESS, 0, NULL); trim_regex = g_regex_new("\n$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, 0, NULL); label = gtk_label_new(_("Find")); panel = gtk_vbox_new(FALSE, 6); scrollable_table = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollable_table), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(panel), scrollable_table, TRUE, TRUE, 0); gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->sidebar_notebook), panel, label); entry = gtk_entry_new(); gtk_entry_set_icon_from_stock(GTK_ENTRY(entry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_FIND); g_signal_connect(entry, "activate", G_CALLBACK(on_activate), NULL); GtkWidget *button_box = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(button_box), entry, TRUE, TRUE, 0); GtkWidget *button = gtk_button_new_with_label(_("Find")); g_signal_connect(button, "clicked", G_CALLBACK(on_click), NULL); gtk_box_pack_end(GTK_BOX(button_box), button, FALSE, TRUE, 0); check_case = gtk_check_button_new_with_label(_("Case Sensitive")); ui_widget_set_tooltip_text(check_case, _("Perform a case-sensitive search.")); gtk_box_pack_end(GTK_BOX(panel), check_case, FALSE, TRUE, 0); gtk_box_pack_end(GTK_BOX(panel), button_box, FALSE, TRUE, 0); gtk_container_set_focus_child(GTK_CONTAINER(panel), entry); GtkTreeViewColumn *number_column, *line_column, *file_column, *text_column; GtkCellRenderer *render; list = gtk_tree_store_new(4, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list)); render = gtk_cell_renderer_text_new(); number_column = gtk_tree_view_column_new_with_attributes("#", render, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), number_column); gtk_tree_view_column_set_alignment(number_column, 1.0); gtk_cell_renderer_set_alignment(render, 1.0, 0.0); gtk_tree_view_column_add_attribute(number_column, render, "text", 0); render = gtk_cell_renderer_text_new(); line_column = gtk_tree_view_column_new_with_attributes("Line", render, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), line_column); gtk_tree_view_column_set_alignment(line_column, 1.0); gtk_cell_renderer_set_alignment(render, 1.0, 0.0); gtk_tree_view_column_add_attribute(line_column, render, "text", 1); render = gtk_cell_renderer_text_new(); file_column = gtk_tree_view_column_new_with_attributes("File", render, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), file_column); gtk_tree_view_column_add_attribute(file_column, render, "text", 2); gtk_tree_view_column_set_cell_data_func(file_column, render, (GtkTreeCellDataFunc)cell_data, NULL, NULL); render = gtk_cell_renderer_text_new(); text_column = gtk_tree_view_column_new_with_attributes("Text", render, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), text_column); gtk_tree_view_column_add_attribute(text_column, render, "text", 3); g_object_unref(GTK_TREE_MODEL(list)); GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); g_signal_connect(select, "changed", G_CALLBACK(selected_row), NULL); gtk_container_add(GTK_CONTAINER(scrollable_table), tree); gtk_widget_show(label); gtk_widget_show_all(panel); g_signal_connect(geany->main_widgets->window, "key-release-event", G_CALLBACK(panel_focus_tab), NULL); GeanyKeyGroup *key_group; key_group = plugin_set_key_group(geany_plugin, "quick_find_keyboard_shortcut", KB_GROUP, NULL); keybindings_set_item(key_group, KB_QUICK_FIND, entry_focus, 0, 0, "quick_find", _("Quick Find..."), NULL); }
/* load individual file details. return TRUE if data there, FALSE if there isn't */ static gboolean LoadIndividualSetting(GKeyFile *gkf,gint iNumber,gchar *Filename) { gchar *pcKey=NULL; gchar *pcTemp; gchar *pcTemp2; gint l; FileData *fd=NULL; /* if loading from local file then no fiilename in file and no number in key*/ if(iNumber==-1) { /* get structure to hold filedetails */ fd=GetFileData(Filename); /* create key */ pcKey=g_strdup("A"); } /* if loading from central file then need to extract filename from A key */ else { pcKey=g_strdup_printf("A%d",iNumber); /* get filename */ pcTemp=(gchar*)(utils_get_setting_string(gkf,"FileData",pcKey,NULL)); /* if null then have reached end of files */ if(pcTemp==NULL) { g_free(pcKey); return FALSE; } fd=GetFileData(pcTemp); g_free(pcTemp); } /* get folding data */ pcKey[0]='B'; if(bRememberFolds==TRUE) fd->pcFolding=(gchar*)(utils_get_setting_string(gkf,"FileData",pcKey,NULL)); else fd->pcFolding=NULL; /* load last saved time */ pcKey[0]='C'; fd->LastChangedTime=utils_get_setting_integer(gkf,"FileData",pcKey,-1); /* get bookmarks */ pcKey[0]='D'; pcTemp=(gchar*)(utils_get_setting_string(gkf,"FileData",pcKey,NULL)); /* pcTemp contains comma seperated numbers (or blank for -1) */ pcTemp2=pcTemp; if(pcTemp!=NULL) for(l=0;l<10;l++) { /* Bookmark entries are initialized to -1, so only need to parse non-empty slots */ if(pcTemp2[0]!=',' && pcTemp2[0]!=0) { fd->iBookmark[l]=strtoll(pcTemp2,NULL,10); while(pcTemp2[0]!=0 && pcTemp2[0]!=',') pcTemp2++; } pcTemp2++; } g_free(pcTemp); /* get position in bookmarked lines */ pcKey[0]='E'; pcTemp=(gchar*)(utils_get_setting_string(gkf,"FileData",pcKey,NULL)); /* pcTemp contains comma seperated numbers (or blank for -1) */ pcTemp2=pcTemp; if(pcTemp!=NULL) for(l=0;l<10;l++) { /* Bookmark entries are initialized to -1, so only need to parse non-empty slots */ if(pcTemp2[0]!=',' && pcTemp2[0]!=0) { fd->iBookmarkLinePos[l]=strtoll(pcTemp2,NULL,10); while(pcTemp2[0]!=0 && pcTemp2[0]!=',') pcTemp2++; } pcTemp2++; } /* get non-numbered bookmarks */ pcKey[0]='F'; if(bRememberBookmarks==TRUE) fd->pcBookmarks=(gchar*)(utils_get_setting_string(gkf,"FileData",pcKey,NULL)); else fd->pcBookmarks=NULL; /* free used memory */ g_free(pcTemp); g_free(pcKey); return TRUE; }