void indent_toggle_tab_width(GtkWidget *text_view) { if (current_tab_width == default_tab_width) if (default_tab_width == 8) current_tab_width = 4; else current_tab_width = 8; else current_tab_width = default_tab_width; indent_refresh_tab_width(text_view); }
void change_text_font_by_selector(GtkWidget *widget) { gchar *current_fontname, *fontname; current_fontname = get_font_name_from_widget(widget); fontname = get_font_name_by_selector( gtk_widget_get_toplevel(widget), current_fontname); if (fontname) { set_text_font_by_name(widget, fontname); indent_refresh_tab_width(widget); } g_free(fontname); g_free(current_fontname); }
gint main(gint argc, gchar **argv) { Conf *conf; GtkItemFactory *ifactory; gchar *stdin_data = NULL; bindtextdomain(PACKAGE, LOCALEDIR); //bindtextdomain ?? bind_textdomain_codeset(PACKAGE, "UTF-8"); // ?? textdomain(PACKAGE); // ?? pub = g_malloc(sizeof(PublicData)); pub->fi = g_malloc(sizeof(FileInfo)); pub->fi->filename = NULL; pub->fi->charset = NULL; pub->fi->charset_flag = FALSE; pub->fi->lineend = LF; parse_args(argc, argv, pub->fi); gtk_init(&argc, &argv); //call before using any gtk fuction g_set_application_name(PACKAGE_NAME); g_print("%s\n", PACKAGE_NAME); #if !GTK_CHECK_VERSION(2, 6, 0) add_about_stock(); #endif pub->mw = create_main_window(); //Find create_main_window conf = g_malloc(sizeof(Conf)); //sends default vlues to load and overwrites in the function conf->width = 600; conf->height = 400; conf->fontname = g_strdup("Monospace 12"); conf->wordwrap = FALSE; conf->linenumbers = FALSE; conf->autoindent = FALSE; load_config_file(conf); //gtk options for GUI gtk_window_set_default_size( GTK_WINDOW(pub->mw->window), conf->width, conf->height); set_text_font_by_name(pub->mw->view, conf->fontname); ifactory = gtk_item_factory_from_widget(pub->mw->menubar); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(ifactory, "/Options/Word Wrap")), conf->wordwrap); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(ifactory, "/Options/Line Numbers")), conf->linenumbers); indent_refresh_tab_width(pub->mw->view); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(ifactory, "/Options/Auto Indent")), conf->autoindent); gtk_widget_show_all(pub->mw->window); g_free(conf->fontname); g_free(conf); #ifdef ENABLE_EMACS check_emacs_key_theme(GTK_WINDOW(pub->mw->window), ifactory); #endif hlight_init(pub->mw->buffer); undo_init(pub->mw->view, gtk_item_factory_get_widget(ifactory, "/Edit/Undo"), gtk_item_factory_get_widget(ifactory, "/Edit/Redo")); // hlight_init(pub->mw->buffer); dnd_init(pub->mw->view); if (pub->fi->filename) file_open_real(pub->mw->view, pub->fi); #ifdef G_OS_UNIX else stdin_data = gedit_utils_get_stdin(); #endif if (stdin_data) { gchar *str; GtkTextIter iter; str = g_convert(stdin_data, -1, "UTF-8", get_default_charset(), NULL, NULL, NULL); g_free(stdin_data); // gtk_text_buffer_set_text(buffer, "", 0); gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter); gtk_text_buffer_insert(pub->mw->buffer, &iter, str, strlen(str)); gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter); gtk_text_buffer_place_cursor(pub->mw->buffer, &iter); gtk_text_buffer_set_modified(pub->mw->buffer, FALSE); gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(pub->mw->view), &iter, 0, FALSE, 0, 0); g_free(str); } if (jump_linenum) { GtkTextIter iter; gtk_text_buffer_get_iter_at_line(pub->mw->buffer, &iter, jump_linenum - 1); gtk_text_buffer_place_cursor(pub->mw->buffer, &iter); // gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(textview), &iter, 0.1, FALSE, 0.5, 0.5); scroll_to_cursor(pub->mw->buffer, 0.25); } set_main_window_title(); // hlight_apply_all(pub->mw->buffer); gtk_main(); return 0; }
gint main(gint argc, gchar **argv) { Conf *conf; gchar *stdin_data = NULL; bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); pub = g_malloc(sizeof(PublicData)); pub->fi = g_malloc(sizeof(FileInfo)); pub->fi->filename = NULL; pub->fi->charset = NULL; pub->fi->charset_flag = FALSE; pub->fi->lineend = LF; parse_args(argc, argv, pub->fi); #if !ENABLE_XINPUT2 gdk_disable_multidevice(); #endif gtk_init(&argc, &argv); g_set_application_name(PACKAGE_NAME); selection_primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY); pub->mw = create_main_window(); conf = g_malloc(sizeof(Conf)); conf->width = 600; conf->height = 400; conf->fontname = g_strdup("Monospace 12"); conf->wordwrap = FALSE; conf->linenumbers = FALSE; conf->autoindent = FALSE; load_config_file(conf); gtk_window_set_default_size( GTK_WINDOW(pub->mw->window), conf->width, conf->height); set_text_font_by_name(pub->mw->view, conf->fontname); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(pub->mw->menubar, "/M/Options/WordWrap")), conf->wordwrap); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(pub->mw->menubar, "/M/Options/LineNumbers")), conf->linenumbers); indent_refresh_tab_width(pub->mw->view); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(pub->mw->menubar, "/M/Options/AutoIndent")), conf->autoindent); gtk_widget_show_all(pub->mw->window); g_free(conf->fontname); g_free(conf); #if ENABLE_EMACS check_emacs_key_theme(GTK_WINDOW(pub->mw->window), pub->mw->menubar); #endif hlight_init(pub->mw->buffer); undo_init(pub->mw->view, gtk_item_factory_get_widget(pub->mw->menubar, "/M/Edit/Undo"), gtk_item_factory_get_widget(pub->mw->menubar, "/M/Edit/Redo")); // hlight_init(pub->mw->buffer); dnd_init(pub->mw->view); if (pub->fi->filename) file_open_real(pub->mw->view, pub->fi); #ifdef G_OS_UNIX else stdin_data = gedit_utils_get_stdin(); #endif if (stdin_data) { gchar *str; GtkTextIter iter; str = g_convert(stdin_data, -1, "UTF-8", get_default_charset(), NULL, NULL, NULL); g_free(stdin_data); // gtk_text_buffer_set_text(buffer, "", 0); gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter); gtk_text_buffer_insert(pub->mw->buffer, &iter, str, strlen(str)); gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter); gtk_text_buffer_place_cursor(pub->mw->buffer, &iter); gtk_text_buffer_set_modified(pub->mw->buffer, FALSE); gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(pub->mw->view), &iter, 0, FALSE, 0, 0); g_free(str); } if (jump_linenum) { GtkTextIter iter; gtk_text_buffer_get_iter_at_line(pub->mw->buffer, &iter, jump_linenum - 1); gtk_text_buffer_place_cursor(pub->mw->buffer, &iter); // gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(textview), &iter, 0.1, FALSE, 0.5, 0.5); scroll_to_cursor(pub->mw->buffer, 0.25); } set_main_window_title(); indent_refresh_tab_width(pub->mw->view); // hlight_apply_all(pub->mw->buffer); gtk_main(); return 0; }