Control: tags - moreinfo Hi Paul,
On 27.04.2023 10:58, Paul Gevers wrote:
Your debdiff was so big that the mail didn't even reach the list. 60 files changed, 7341 insertions(+), 6240 deletions(-)
As you can see in a diff from 0.8.1 to 0.8.3 [1] also generated UI files and translations changed which makes the debdiff between both packages huge. I created a diff for the upstream changes in the src folder between 0.8.1 and 0.8.3 which should be less bloated and attach it to this email.
Best regards, Martin[1] https://github.com/alexandervdm/gummi/compare/0.8.1...0.8.3#files_bucket
diff --git a/Makefile b/Makefile index 8e8911b..930b1ed 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ TARGET=gummi OBJS = main.o gui/gui-main.o gui/gui-prefs.o gui/gui-menu.o gui/gui-search.o gui/gui-import.o gui/gui-preview.o gui/gui-tabmanager.o gui/gui-project.o gui/gui-snippets.o gui/gui-infoscreen.o compile/texlive.o compile/rubber.o compile/latexmk.o motion.o external.o latex.o editor.o utils.o configfile.o iofunctions.o environment.o project.o importer.o tabmanager.o template.o biblio.o snippets.o signals.o -CFLAGS=-g -Wall -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -export-dynamic -I. `pkg-config --cflags --libs gtk+-3.0 gthread-2.0 gtksourceview-3.0 cairo poppler-glib gtkspell3-3.0 synctex zlib` -lm -DUSE_SYNCTEX1 -DGUMMI_LOCALES="\"/usr/share/locale\"" -DGUMMI_DATA="\"$$PWD/../data\"" -DGUMMI_LIBS="\"$$PWD/../lib\"" +CFLAGS=-g -Wall -Wno-deprecated-declarations -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -export-dynamic -I. `pkg-config --cflags --libs gtk+-3.0 gthread-2.0 gtksourceview-3.0 cairo poppler-glib gtkspell3-3.0 synctex zlib` -lm -DUSE_SYNCTEX2 -DGUMMI_LOCALES="\"/usr/share/locale\"" -DGUMMI_DATA="\"$$PWD/../data\"" -DGUMMI_LIBS="\"$$PWD/../lib\"" gummi: $(OBJS) $(CC) -o $(TARGET) $(OBJS) $(CFLAGS) diff --git a/configfile.c b/configfile.c index fefda66..a6a338f 100644 --- a/configfile.c +++ b/configfile.c @@ -49,9 +49,11 @@ const gchar default_config[] = "mainwindow_max = false\n" "toolbar = true\n" "statusbar = true\n" +"rightpane = true\n" "snippets = true\n" "[Editor]\n" -"font = Monospace 14\n" +"font_str = Monospace 14\n" +"font_css = * { font-family: Monospace; font-size: 14px; }\n" "line_numbers = true\n" "highlighting = true\n" "textwrapping = true\n" diff --git a/constants.h b/constants.h index 0eeee30..439c0fa 100644 --- a/constants.h +++ b/constants.h @@ -35,7 +35,7 @@ // Gummi defs: #define C_PACKAGE "gummi" #define C_PACKAGE_NAME "Gummi" -#define C_PACKAGE_VERSION "0.8.1" +#define C_PACKAGE_VERSION "0.8.3" #define C_PACKAGE_COMMENTS "Simple LaTeX Editor for GTK+" #define C_PACKAGE_COPYRIGHT "Copyright \xc2\xa9 2009\n\n"\ "Alexander van der Meij\n"\ @@ -94,7 +94,7 @@ "Arabic: Hamad Mohammad\n" \ "Brazilian-Portugese: Fernando Cruz, Alexandre Guimarães\n" \ "Catalan: Marc Vinyals\n" \ -"Chinese (Simplified): Mathlab pass\n" \ +"Chinese (Simplified): Mathlab pass, yjwork-cn\n" \ "Chinese (Traditional): Wei-Ning Huang\n" \ "Czech: Přemysl Janouch\n" \ "Danish: Jack Olsen\n" \ @@ -103,6 +103,7 @@ "German: Thomas Niederprüm\n" \ "Greek: Dimitris Leventeas\n" \ "Hungarian: Balázs Meskó\n" \ +"Interlingue: OIS\n" \ "Italian: Salvatore Vassallo\n" \ "Polish: Hubert Kowalski\n" \ "Portugese: Alexandre Guimarães\n" \ diff --git a/editor.c b/editor.c index 5c91857..b97292b 100644 --- a/editor.c +++ b/editor.c @@ -190,7 +190,7 @@ void editor_fileinfo_update (GuEditor* ec, const gchar* filename) { // directory should exist, but if not create ~/.cache/gummi: if (!g_file_test (C_TMPDIR, G_FILE_TEST_IS_DIR)) { - slog (L_WARNING, ".cache directory does not exist, creating..\n"); + slog (L_WARNING, "gummi cache directory does not exist, creating..\n"); g_mkdir_with_parents (C_TMPDIR, DIR_PERMS); } @@ -313,7 +313,7 @@ void editor_sourceview_config (GuEditor* ec) { const gchar* style_scheme = config_get_string ("Editor", "style_scheme"); editor_set_style_scheme_by_id (ec, style_scheme); - editor_set_font (ec, config_get_string ("Editor", "font")); + editor_set_font (ec, config_get_string ("Editor", "font_css")); gtk_source_view_set_show_line_numbers ( GTK_SOURCE_VIEW (ec->view), @@ -724,15 +724,8 @@ void editor_redo_change (GuEditor* ec) { } } -void editor_set_font (GuEditor* ec, const gchar* font) { - // surely there has to be a better solution to transform - // a string like 'Monospace 12' into css syntax right..? - gchar** font_elems = g_strsplit (font, " ", BUFSIZ); - gchar* style = g_strdup_printf ("* { font: %spx '%s'; }", - font_elems[1], font_elems[0]); - - gtk_css_provider_load_from_data (ec->css, style, -1, NULL); - g_free (style); +void editor_set_font (GuEditor* ec, const gchar* font_css) { + gtk_css_provider_load_from_data (ec->css, font_css, -1, NULL); } diff --git a/editor.h b/editor.h index 2e42815..03a279a 100644 --- a/editor.h +++ b/editor.h @@ -105,7 +105,7 @@ void editor_scroll_to_cursor (GuEditor* ec); void editor_scroll_to_line (GuEditor* ec, gint line); void editor_undo_change (GuEditor* ec); void editor_redo_change (GuEditor* ec); -void editor_set_font (GuEditor* ec, const gchar* font); +void editor_set_font (GuEditor* ec, const gchar* font_css); void editor_set_style_scheme_by_id (GuEditor* ec, const gchar* id); void set_style_fg_bg (GObject* obj, GtkSourceStyleScheme* scheme, gchar* styleName, gchar* defaultBG); diff --git a/external.c b/external.c index 60cafb0..900683a 100644 --- a/external.c +++ b/external.c @@ -34,8 +34,8 @@ /* local functions */ static gchar* get_version_output (const gchar* command, int linenr); -static gchar* version_latexmk (const gchar* output); -static gchar* version_rubber (const gchar* output); +static gchar* version_latexmk (gchar* output); +static gchar* version_rubber (gchar* output); static gdouble get_texlive_version (void); @@ -80,16 +80,19 @@ gdouble external_version2 (ExternalProg program) { } gchar* external_version (const gchar* program) { - const gchar* getversion = g_strdup_printf("%s --version", program); - Tuple2 cmdgetv = utils_popen_r (getversion, NULL); - gchar* output = (gchar*)cmdgetv.second; + gchar* version_output; + gchar* result; - gchar* result = g_strdup ("Unknown, please report a bug"); + const gchar* version_cmd = g_strdup_printf("%s --version", program); + Tuple2 cmdgetv = utils_popen_r (version_cmd, NULL); + version_output = (gchar*)cmdgetv.second; - if (output == NULL) return result; - - gchar** lines = g_strsplit(output, "\n", BUFSIZ); - result = lines[0]; + if (version_output == NULL || g_str_equal (version_output, "")) { + return g_strdup_printf("Unknown, please report a bug"); + } + else { + result = g_strstrip (version_output); + } /* pdfTeX 3.1415926-1.40.10 (TeX Live 2009) pdfTeX 3.1415926-1.40.11-2.2 (TeX Live 2010) @@ -101,7 +104,7 @@ gchar* external_version (const gchar* program) { result = version_rubber (result); } else if (STR_EQU (program, C_LATEXMK)) { - result = version_latexmk (lines[1]); + result = version_latexmk (result); } return result; @@ -145,16 +148,20 @@ static gdouble get_texlive_version (void) { return version; } -static gchar* version_rubber (const gchar* output) { - /* format: Rubber version: 1.1 */ - gchar** version = g_strsplit (output, " ", BUFSIZ); - return version[2]; +static gchar* version_rubber (gchar* output) { + // format: Rubber version: 1.1 + gchar** outarr = g_strsplit (output, " ", BUFSIZ); + gchar* version = g_strdup (outarr [g_strv_length(outarr) - 1]); + + g_strfreev (outarr); + return version; } -static gchar* version_latexmk (const gchar* output) { - /* latexmk --version seems to print the requested information after a \n - format: Latexmk, John Collins, 24 March 2011. Version 4.23a */ +static gchar* version_latexmk (gchar* output) { + // format: Latexmk, John Collins, 24 March 2011. Version 4.23a + gchar** outarr = g_strsplit (output, " ", BUFSIZ); + gchar* version = g_strdup (outarr [g_strv_length(outarr) - 1]); - gchar** version = g_strsplit (output, " ", BUFSIZ); - return version[7]; + g_strfreev (outarr); + return version; } diff --git a/gui/gui-main.c b/gui/gui-main.c index 6d4c759..d5f9f71 100644 --- a/gui/gui-main.c +++ b/gui/gui-main.c @@ -107,7 +107,9 @@ GummiGui* gui_init (GtkBuilder* builder) { g->menu_toolbar = GTK_CHECK_MENU_ITEM (gtk_builder_get_object (builder, "menu_toolbar")); g->menu_statusbar = - GTK_CHECK_MENU_ITEM(gtk_builder_get_object (builder, "menu_statusbar")); + GTK_CHECK_MENU_ITEM (gtk_builder_get_object (builder, "menu_statusbar")); + g->menu_rightpane = + GTK_CHECK_MENU_ITEM (gtk_builder_get_object (builder, "menu_rightpane")); g->statusid = gtk_statusbar_get_context_id (GTK_STATUSBAR (g->statusbar), "Gummi"); g->recent[0] = @@ -226,6 +228,14 @@ GummiGui* gui_init (GtkBuilder* builder) { gtk_widget_hide (GTK_WIDGET (g->statusbar)); } + if (config_get_boolean ("Interface", "rightpane")) { + gtk_check_menu_item_set_active (g->menu_rightpane, TRUE); + gtk_widget_show (GTK_WIDGET (g->rightpane)); + } else { + gtk_check_menu_item_set_active (g->menu_rightpane, FALSE); + gtk_widget_hide (GTK_WIDGET (g->rightpane)); + } + g->menu_autosync = GTK_CHECK_MENU_ITEM (gtk_builder_get_object (builder, "menu_autosync")); @@ -247,6 +257,11 @@ GummiGui* gui_init (GtkBuilder* builder) { } void gui_main (GtkBuilder* builder) { + #ifdef WIN32 + // force win32 builds to use a native looking theme + g_object_set (gtk_settings_get_default(), "gtk-theme-name", "win32", NULL); + #endif + gtk_builder_connect_signals (builder, NULL); gtk_widget_show_all (GTK_WIDGET (gui->mainwindow)); @@ -553,7 +568,8 @@ void on_template_rowitem_edited (GtkWidget* widget, gchar *path, gchar* filenm, G_MODULE_EXPORT void on_template_cursor_changed (GtkTreeView *tree, gpointer data) { - if (!gtk_tree_view_get_selection (tree) == 0) { + + if (gtk_tree_view_get_selection (tree)) { gtk_widget_set_sensitive (gummi->templ->template_open, TRUE); } } diff --git a/gui/gui-main.h b/gui/gui-main.h index d492c55..6adec43 100644 --- a/gui/gui-main.h +++ b/gui/gui-main.h @@ -83,6 +83,7 @@ struct _GummiGui { GtkCheckMenuItem* menu_snippets; GtkCheckMenuItem* menu_toolbar; GtkCheckMenuItem* menu_statusbar; + GtkCheckMenuItem* menu_rightpane; GtkCheckMenuItem* menu_autosync; GtkMenuItem* recent[5]; gint insens_widget_size; diff --git a/gui/gui-menu.c b/gui/gui-menu.c index 3834189..6ff46c9 100644 --- a/gui/gui-menu.c +++ b/gui/gui-menu.c @@ -179,6 +179,8 @@ gboolean on_menu_quit_activate (void) { gint length = g_list_length (gummi->tabmanager->tabs); int i = 0; + motion_pause_compile_thread (gummi->motion); + for(i = 0; i < length; i++){ gtk_notebook_set_current_page(gui->tabmanagergui->notebook, i); tabmanager_set_active_tab (i); @@ -320,6 +322,19 @@ void on_menu_toolbar_toggled (GtkWidget *widget, void *user) { } } +G_MODULE_EXPORT +void on_menu_rightpane_toggled (GtkWidget *widget, void *user) { + if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) { + gtk_widget_show (GTK_WIDGET (gui->rightpane)); + config_set_boolean ("Interface", "rightpane", TRUE); + gtk_toggle_tool_button_set_active (gui->previewgui->preview_pause, FALSE); + } else { + gtk_widget_hide (GTK_WIDGET (gui->rightpane)); + config_set_boolean ("Interface", "rightpane", FALSE); + gtk_toggle_tool_button_set_active (gui->previewgui->preview_pause, TRUE); + } +} + G_MODULE_EXPORT void on_menu_fullscreen_toggled (GtkWidget *widget, void *user) { if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) diff --git a/gui/gui-menu.h b/gui/gui-menu.h index 1f7bcce..5deb039 100644 --- a/gui/gui-menu.h +++ b/gui/gui-menu.h @@ -49,8 +49,4 @@ struct _GuMenuGui { GuMenuGui* menugui_init (GtkBuilder* builder); void on_menu_close_activate (GtkWidget *widget, void* user); -#ifdef WIN32 - void on_menu_donate_activate (GtkWidget *widget, void* user); -#endif - #endif /* __GUMMI_GUI_MENU_H__ */ diff --git a/gui/gui-prefs.c b/gui/gui-prefs.c index ed63f79..172b708 100644 --- a/gui/gui-prefs.c +++ b/gui/gui-prefs.c @@ -149,9 +149,9 @@ GuPrefsGui* prefsgui_init (GtkWindow* mainwindow) { // list available languages if (g_file_test ( - g_find_program_in_path("enchant-lsmod"), G_FILE_TEST_EXISTS)) { + g_find_program_in_path("enchant-lsmod-2"), G_FILE_TEST_EXISTS)) { - Tuple2 pret = utils_popen_r ("enchant-lsmod -list-dicts", NULL); + Tuple2 pret = utils_popen_r ("enchant-lsmod-2 -list-dicts", NULL); if (pret.second != NULL) { gchar** output = g_strsplit((gchar*)pret.second, "\n", BUFSIZ); gchar** elems = NULL; @@ -247,8 +247,16 @@ static void set_tab_editor_settings (GuPrefsGui* prefs) { static void set_tab_fontcolor_settings (GuPrefsGui* prefs) { gtk_font_chooser_set_font (GTK_FONT_CHOOSER (prefs->editor_font), - config_get_string ("Editor", "font")); + config_get_string ("Editor", "font_str")); prefsgui_apply_style_scheme(prefs); + + // set default font on all tabs + GList* tab = gummi->tabmanager->tabs; + while (tab) { + editor_set_font (GU_TAB_CONTEXT (tab->data)->editor, + config_get_string ("Editor", "font_css")); + tab = g_list_next (tab); + } } static void set_tab_defaulttext_settings (GuPrefsGui* prefs) { @@ -654,15 +662,24 @@ void on_cache_size_value_changed (GtkWidget* widget, void* user) { } G_MODULE_EXPORT -void on_editor_font_set (GtkWidget* widget, void* user) { - gchar* font = gtk_font_chooser_get_font ( GTK_FONT_CHOOSER (widget)); - GList* tab = gummi->tabmanager->tabs; +void on_editor_font_change (GtkWidget* widget, void* user) { + PangoFontDescription* font_desc; + gchar* font_css; + gchar* font_str; + + font_str = gtk_font_chooser_get_font ( GTK_FONT_CHOOSER (widget)); + config_set_string ("Editor", "font_str", font_str); + slog (L_INFO, "setting font to %s\n", font_str); + g_free (font_str); - slog (L_INFO, "setting font to %s\n", font); - config_set_string ("Editor", "font", font); + font_desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (widget)); + font_css = utils_pango_font_desc_to_css (font_desc); + config_set_string ("Editor", "font_css", font_css); + // set new font on all tabs + GList* tab = gummi->tabmanager->tabs; while (tab) { - editor_set_font (GU_TAB_CONTEXT (tab->data)->editor, font); + editor_set_font (GU_TAB_CONTEXT (tab->data)->editor, font_css); tab = g_list_next (tab); } } @@ -794,8 +811,9 @@ G_MODULE_EXPORT void on_styleschemes_treeview_cursor_changed (GtkTreeView* treeview, void* user) { gchar* id = NULL; gchar* name = NULL; - GList* tab = gummi->tabmanager->tabs; + GList* tab; GtkTreeIter iter; + GtkTreeModel* model = GTK_TREE_MODEL (gtk_tree_view_get_model (treeview)); GtkTreeSelection* selection = gtk_tree_view_get_selection (treeview); diff --git a/gui/gui-prefs.h b/gui/gui-prefs.h index 7d7b274..fc06db6 100644 --- a/gui/gui-prefs.h +++ b/gui/gui-prefs.h @@ -93,7 +93,7 @@ void on_tabwidth_value_changed (GtkWidget* widget, void* user); void on_configure_snippets_clicked (GtkWidget* widget, void* user); void on_autosave_value_changed (GtkWidget* widget, void* user); void on_compile_value_changed (GtkWidget* widget, void* user); -void on_editor_font_set (GtkWidget* widget, void* user); +void on_editor_font_change (GtkWidget* widget, void* user); void on_combo_typesetter_changed (GtkWidget* widget, void* user); void on_combo_language_changed (GtkComboBoxText* widget, void* user); void on_combo_compilescheme_changed (GtkWidget* widget, void* user); diff --git a/gui/gui-preview.c b/gui/gui-preview.c index ab39b81..e4d3ac6 100644 --- a/gui/gui-preview.c +++ b/gui/gui-preview.c @@ -141,9 +141,7 @@ static gboolean remove_page_rendering (GuPreviewGui* pc, gint page); // Functions for syncronizing editor and preview via SyncTeX static gboolean synctex_run_parser (GuPreviewGui* pc, GtkTextIter *sync_to, gchar* tex_file); -#if HAVE_POPPLER_PAGE_GET_SELECTED_TEXT static void synctex_filter_results (GuPreviewGui* pc, GtkTextIter *sync_to); -#endif static void synctex_scroll_to_node (GuPreviewGui* pc, SyncNode* node); static SyncNode* synctex_one_node_found (GuPreviewGui* pc); static void synctex_merge_nodes (GuPreviewGui* pc); @@ -172,7 +170,10 @@ GuPreviewGui* previewgui_init (GtkBuilder * builder) { p->toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "preview_toolbar")); p->combo_sizes = - GTK_COMBO_BOX (gtk_builder_get_object (builder, "combo_sizes")); + GTK_COMBO_BOX (gtk_builder_get_object (builder, "combo_preview_size")); + p->model_sizes = + GTK_TREE_MODEL (gtk_builder_get_object (builder, "model_preview_size")); + p->page_next = GTK_WIDGET (gtk_builder_get_object (builder, "page_next")); p->page_prev = GTK_WIDGET (gtk_builder_get_object (builder, "page_prev")); p->page_label = GTK_WIDGET (gtk_builder_get_object (builder, "page_label")); @@ -547,8 +548,11 @@ gboolean on_document_compiled (gpointer data) { previewgui_start_errormode (pc, "compile_error"); } else { if (!pc->uri) { - - gchar* uri = g_filename_to_uri (editor->pdffile, NULL, NULL); + // NOTE: g_filename_{to|from}_uri functions (correctly) + // encode special characters like space with % + hexvalue + // but we don't do that elsewhere so use custom concat for now + gchar* uri = g_strconcat ("file://", editor->pdffile, NULL); + //gchar* uri = g_filename_to_uri (editor->pdffile, NULL, NULL); previewgui_set_pdffile (pc, uri); g_free(uri); @@ -928,7 +932,7 @@ static void load_document(GuPreviewGui* pc, gboolean update) { void previewgui_set_pdffile (GuPreviewGui* pc, const gchar *uri) { //L_F_DEBUG; GError *error = NULL; - + previewgui_cleanup_fds (pc); pc->uri = g_strdup(uri); @@ -949,31 +953,48 @@ void previewgui_set_pdffile (GuPreviewGui* pc, const gchar *uri) { // Restore scale and fit mode if (!g_active_tab->fit_mode) { + const gchar* conf_zoom = config_get_string ("Preview", "zoom_mode"); - gint new_fit, new_zoom; - - // TODO: build a dict like structure combining zoom fit strs with - // id (combo) so we don't have to do this verbose stuff all over the place - if (STR_EQU (conf_zoom, "Best Fit")) new_fit = 0, new_zoom = 0; - else - if (STR_EQU (conf_zoom, "Fit Page Width")) new_fit = 1, new_zoom = 1; - else { - new_fit = 2; - if (STR_EQU (conf_zoom, "50%")) new_zoom = 2; - else if (STR_EQU (conf_zoom, "70%")) new_zoom = 3; - else if (STR_EQU (conf_zoom, "85%")) new_zoom = 4; - else if (STR_EQU (conf_zoom, "100%")) new_zoom = 5; - else if (STR_EQU (conf_zoom, "125%")) new_zoom = 6; - else if (STR_EQU (conf_zoom, "150%")) new_zoom = 7; - else if (STR_EQU (conf_zoom, "200%")) new_zoom = 8; - else if (STR_EQU (conf_zoom, "300%")) new_zoom = 9; - else if (STR_EQU (conf_zoom, "400%")) new_zoom = 10; - else slog (L_ERROR, "should not happen\n"); + + GtkTreeIter iter; + gboolean iter_next; + gint iter_count = 0; + + iter_next = gtk_tree_model_get_iter_first (pc->model_sizes, &iter); + + while (iter_next) { + gchar *str_data; + gtk_tree_model_get (pc->model_sizes, &iter, 0, &str_data, -1); + + // match zoom/fit mode from configfile with mapping from glade: + if (STR_EQU (conf_zoom, str_data)) { + + // set zoom_mode + g_active_tab->zoom_mode = iter_count; + + // set fit_mode + switch (iter_count) { + case FIT_BOTH: + g_active_tab->fit_mode = FIT_BOTH; + break; + case FIT_WIDTH: + g_active_tab->fit_mode = FIT_WIDTH; + break; + default: + g_active_tab->fit_mode = FIT_NUMERIC; + break; + } + g_free (str_data); + break; + } + + iter_next = gtk_tree_model_iter_next (pc->model_sizes, &iter); + iter_count += 1; } - g_active_tab->fit_mode = new_fit; - g_active_tab->zoom_mode = new_zoom; } + // TODO: further cleanup above and below please! + g_signal_handler_block(pc->combo_sizes, pc->combo_sizes_changed_handler); switch (g_active_tab->fit_mode) { @@ -1031,24 +1052,23 @@ void previewgui_refresh (GuPreviewGui* pc, GtkTextIter *sync_to, gchar* tex_file synctex_run_parser(pc, sync_to, tex_file)) { SyncNode *node; - if ((node = synctex_one_node_found(pc)) == NULL) { - // See if the nodes are so close they all fit in the window - // in that case we just merge them + if (synctex_one_node_found(pc) == NULL) { + // See if the nodes are so close they all fit in + // the window - in that case we just merge them synctex_merge_nodes(pc); } -#if HAVE_POPPLER_PAGE_GET_SELECTED_TEXT - if ((node = synctex_one_node_found(pc)) == NULL) { + if (synctex_one_node_found(pc) == NULL) { // Search for words in the pdf synctex_filter_results(pc, sync_to); } - // Here we could try merging again - but only with nodes which - // contained the searched text -#endif - // If we have only one node left/selected, scroll ot it. + // Here we could try merging again - but only with + // nodes which contained the searched text + + // If we have only one node left/selected, scroll to it. if ((node = synctex_one_node_found(pc)) != NULL) { - synctex_scroll_to_node(pc, node); + synctex_scroll_to_node(pc, node); } } else { @@ -1108,7 +1128,6 @@ static gboolean synctex_run_parser(GuPreviewGui* pc, GtkTextIter *sync_to, gchar return TRUE; } -#if HAVE_POPPLER_PAGE_GET_SELECTED_TEXT static void synctex_filter_results(GuPreviewGui* pc, GtkTextIter *sync_to) { // First look if we even have to filter... @@ -1167,8 +1186,6 @@ static void synctex_filter_results(GuPreviewGui* pc, GtkTextIter *sync_to) { g_free(word); } } -#endif - static SyncNode* synctex_one_node_found(GuPreviewGui* pc) { @@ -1455,7 +1472,7 @@ void previewgui_scroll_to_xy (GuPreviewGui* pc, gdouble x, gdouble y) { void previewgui_save_position (GuPreviewGui* pc) { //L_F_DEBUG; - if (g_active_tab != NULL) { + if (g_active_tab != NULL && !pc->errormode) { g_active_tab->scroll_x = gtk_adjustment_get_value (pc->hadj); g_active_tab->scroll_y = gtk_adjustment_get_value (pc->vadj); block_handlers_current_page(pc); diff --git a/gui/gui-preview.h b/gui/gui-preview.h index 8984d4e..9b87936 100644 --- a/gui/gui-preview.h +++ b/gui/gui-preview.h @@ -105,7 +105,9 @@ struct _GuPreviewGui { GtkToggleToolButton* preview_pause; GtkWidget* errorpanel; - GtkComboBox* combo_sizes; + + GtkComboBox* combo_sizes; + GtkTreeModel* model_sizes; gulong page_input_changed_handler; gulong combo_sizes_changed_handler; diff --git a/importer.c b/importer.c index 574ea54..0d317df 100644 --- a/importer.c +++ b/importer.c @@ -121,12 +121,11 @@ const gchar* importer_generate_image (const gchar* filepath, const gchar* captio gchar scale_str[16] = { 0 }; gchar* loc = NULL; - /* clear previous data */ + // clear previous data result[0] = 0; - // Filepath notation corrections for Windows systems: #ifdef WIN32 - gchar* path = g_strjoinv("/", g_strsplit(filepath, "\\", -1)); + // filepath notation correction for win32 systems: if (utils_subinstr (" ", filepath, FALSE)) { editor_insert_package (g_active_editor, "grffile", "space"); } @@ -134,7 +133,7 @@ const gchar* importer_generate_image (const gchar* filepath, const gchar* captio snprintf (scale_str, 16, "%.2f", scale); - /* some locales use ',' as seperator, replace them as '.' */ + // some locales use ',' as seperator, replace them as '.' if ( (loc = strstr (scale_str, ","))) *loc = '.'; diff --git a/iofunctions.c b/iofunctions.c index e7d5c72..05402c7 100644 --- a/iofunctions.c +++ b/iofunctions.c @@ -101,22 +101,20 @@ void iofunctions_real_load_file (GObject* hook, const gchar* filename) { GError* err = NULL; gchar* text = NULL; gchar* decoded = NULL; - gboolean result; GuEditor* ec = NULL; - ec = gummi_get_active_editor(); - - /* get the file contents */ - if (FALSE == (result = g_file_get_contents (filename, &text, NULL, &err))) { + if (FALSE == (g_file_get_contents (filename, &text, NULL, &err))) { slog (L_G_ERROR, "g_file_get_contents (): %s\n", err->message); g_error_free (err); iofunctions_load_default_text (FALSE); return; } + if (NULL == (decoded = iofunctions_decode_text (text))) goto cleanup; - editor_fill_buffer (ec, decoded); + ec = gummi_get_active_editor(); + editor_fill_buffer (gummi_get_active_editor(), decoded); gtk_text_buffer_set_modified (GTK_TEXT_BUFFER(ec->buffer), FALSE); cleanup: @@ -155,18 +153,14 @@ void iofunctions_real_save_file (GObject* hook, GObject* savecontext) { encoded = iofunctions_encode_text (text); - /* set the contents of the file to the text from the buffer */ + // set the contents of the file to the text from the buffer if (filename != NULL) { if (! (result = g_file_set_contents (filename, encoded, -1, &err))) { slog (L_ERROR, "g_file_set_contents (): %s\n", err->message); + g_error_free (err); } } - if (result == FALSE) { - slog (L_G_ERROR, _("%s\nPlease try again later."), err->message); - g_error_free (err); - } - g_free (encoded); g_free (text); g_object_unref (savecontext); diff --git a/latex.c b/latex.c index 4edd319..ddacb29 100644 --- a/latex.c +++ b/latex.c @@ -264,7 +264,7 @@ void latex_export_pdffile (GuLatex* lc, GuEditor* ec, const gchar* path, } } if (!utils_copy_file (ec->pdffile, savepath, &err)) { - slog (L_G_ERROR, _("Unable to export PDF file.\n\n%s"), + slog (L_G_ERROR, _("Unable to export PDF file: %s\n"), err->message); g_error_free (err); } diff --git a/motion.c b/motion.c index 5e93b58..4dca5c7 100644 --- a/motion.c +++ b/motion.c @@ -104,13 +104,12 @@ void motion_resume_compile_thread (GuMotion* m) { void motion_kill_typesetter (GuMotion* m) { if (*m->typesetter_pid) { - gchar* command = NULL; /* Kill children spawned by typesetter command/script, don't know * how to do this programatically yet(glib doesn't not provides any * function for killing a process), so use pkill for now. For * win32 there's currently nothing we can do about it. */ #ifndef WIN32 - command = g_strdup_printf("pkill -15 -P %d", *m->typesetter_pid); + gchar* command = g_strdup_printf("pkill -15 -P %d", *m->typesetter_pid); system(command); g_free(command); diff --git a/snippets.c b/snippets.c index dc18afb..4c28650 100644 --- a/snippets.c +++ b/snippets.c @@ -196,24 +196,24 @@ gchar* snippets_get_value (GuSnippets* sc, const gchar* term) { } void snippets_set_accelerator (GuSnippets* sc, gchar* config) { - /* config has the form: Key,Accel_key,Name */ + // config has the form: Key,Accel_key,Name GClosure* closure = NULL; GdkModifierType mod; guint keyval = 0; gchar** configs = g_strsplit (config, ",", 0); - Tuple2* data = g_new0 (Tuple2, 1); - Tuple2* closure_data = g_new0 (Tuple2, 1); - /* Return if config does not contains accelerator */ + // return if configs does not contain accelerator if (strlen (configs[1]) == 0) { g_strfreev (configs); return; } + Tuple2* data = g_new0 (Tuple2, 1); + Tuple2* closure_data = g_new0 (Tuple2, 1); + data->first = (gpointer)sc; data->second = (gpointer)g_strdup (configs[0]); - closure = g_cclosure_new (G_CALLBACK (snippets_accel_cb), data, NULL); closure_data->first = (gpointer)data->second; closure_data->second = (gpointer)closure; @@ -221,7 +221,7 @@ void snippets_set_accelerator (GuSnippets* sc, gchar* config) { sc->closure_data = g_list_append (sc->closure_data, closure_data); gtk_accelerator_parse (configs[1], &keyval, &mod); - /* Return without connect if accel is not valid */ + // return without connect if accel is not valid if (!gtk_accelerator_valid (keyval, mod)) return; snippets_accel_connect (sc, keyval, mod, closure); @@ -410,7 +410,7 @@ void snippets_accel_connect (GuSnippets* sc, guint keyval, GdkModifierType mod, acc = gtk_accelerator_get_label (keyval, gtk_accelerator_get_default_mod_mask () & mod); - slog (L_DEBUG, "Accelerator `%s' connected\n", acc); + slog (L_DEBUG, "Accelerator '%s' connected\n", acc); g_free (acc); } @@ -430,9 +430,9 @@ void snippets_accel_disconnect (GuSnippets* sc, const gchar* key) { if (current) { gtk_accel_group_disconnect (sc->accel_group, closure_data->second); sc->closure_data = g_list_remove (sc->closure_data, closure_data); - g_free (closure_data); - slog (L_DEBUG, "Accelerator for `%s' disconnected\n", + slog (L_DEBUG, "Accelerator for '%s' disconnected\n", closure_data->first); + g_free (closure_data); } } @@ -561,7 +561,7 @@ void snippet_info_initial_expand (GuSnippetInfo* info, GuEditor* ec) { GHashTable* map = NULL; GList* current = NULL; gchar* text = NULL; - gint key = 0; + glong key = 0; map = g_hash_table_new (NULL, NULL); current = g_list_first (info->einfo); diff --git a/utils.c b/utils.c index 264a248..4fce9f5 100644 --- a/utils.c +++ b/utils.c @@ -162,6 +162,92 @@ gint utils_save_reload_dialog (const gchar* message) { return ret; } +static gchar* css_add (gchar* base, gchar* property, const gchar* value) { + // helper to create css pairs for utils_pango_font_desc_to_css() + return (g_strconcat (base, property, ": ", value, "; ", NULL)); +} + +gchar* utils_pango_font_desc_to_css (PangoFontDescription* font_desc) { +PangoFontMask font_mask; + gchar* result = NULL; + gchar* val = NULL; + + // Generate css by analysing PangoFontDescription structure: + // + // selector { + // property1: value1; + // property2: value2; + // propertyN: valueN; + // } + + font_mask = pango_font_description_get_set_fields (font_desc); + + // add selector: + result = "* { "; + + // add font family: + if (font_mask & PANGO_FONT_MASK_FAMILY) { + result = css_add (result, "font-family", + pango_font_description_get_family (font_desc)); + } + + // add font slant styling: + if (font_mask & PANGO_FONT_MASK_STYLE) { + switch (pango_font_description_get_style (font_desc)) { + case PANGO_STYLE_NORMAL: val = "normal"; break; + case PANGO_STYLE_OBLIQUE: val = "oblique"; break; + case PANGO_STYLE_ITALIC: val = "italic"; break; + } + result = css_add (result, "font-style", val); + } + + // add font capitalization variant: + if (font_mask & PANGO_FONT_MASK_VARIANT) { + switch (pango_font_description_get_variant (font_desc)) { + case PANGO_VARIANT_NORMAL: val = "normal"; break; + case PANGO_VARIANT_SMALL_CAPS: val = "small-caps"; break; + } + result = css_add (result, "font-variant", val); + } + + // add font boldness / weight: + if (font_mask & PANGO_FONT_MASK_WEIGHT) { + gint weight = (gint) pango_font_description_get_weight (font_desc); + result = css_add (result, "font-weight", g_strdup_printf ("%d", weight)); + } + + // add font stretch: + if (font_mask & PANGO_FONT_MASK_STRETCH) { + switch (pango_font_description_get_stretch (font_desc)) { + case PANGO_STRETCH_ULTRA_CONDENSED: val = "ultra-condensed"; break; + case PANGO_STRETCH_EXTRA_CONDENSED: val = "extra-condensed"; break; + case PANGO_STRETCH_CONDENSED: val = "condensed"; break; + case PANGO_STRETCH_SEMI_CONDENSED: val = "semi-condensed"; break; + case PANGO_STRETCH_NORMAL: val = "normal"; break; + case PANGO_STRETCH_SEMI_EXPANDED: val = "semi-expanded"; break; + case PANGO_STRETCH_EXPANDED: val = "expanded"; break; + case PANGO_STRETCH_EXTRA_EXPANDED: val = "extra-expanded"; break; + case PANGO_STRETCH_ULTRA_EXPANDED: val = "ultra-expanded"; break; + } + result = css_add (result, "font-stretch", val); + } + + // add font size: + if (font_mask & PANGO_FONT_MASK_SIZE) { + gint size = pango_font_description_get_size (font_desc); + + if (!pango_font_description_get_size_is_absolute (font_desc)) { + size = size / PANGO_SCALE; + } + result = css_add (result, "font-size", g_strdup_printf("%dpx", size)); + } + + // add closing bracket + result = g_strconcat (result, "}", NULL); + + return result; +} + gint utils_yes_no_dialog (const gchar* message) { GtkWidget* dialog; gint ret = 0; diff --git a/utils.h b/utils.h index 527db7c..7c2f66b 100644 --- a/utils.h +++ b/utils.h @@ -120,8 +120,8 @@ gint utils_yes_no_dialog (const gchar* message); gint utils_save_reload_dialog (const gchar* message); gboolean utils_path_exists (const gchar* path); gboolean utils_uri_path_exists (const gchar* uri); -gboolean utils_set_file_contents (const gchar *filename, const gchar *text, - gssize length); +gboolean utils_set_file_contents (const gchar *filename, const gchar *text, gssize length); +gchar* utils_pango_font_desc_to_css (PangoFontDescription* font_desc); /** * utils_copy_file:
signature.asc
Description: PGP signature