-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix preview for files in projects #37
base: master
Are you sure you want to change the base?
Conversation
This patch aims to fix alexandervdm#13. When opening a project, each file-editor receives a pointer to the editor instance of the root file. After saving a non-root file of a project, Gummi will compile the pdf as if the root file was changed. Note: This doesn't provide a live-preview for non-root files, but at least it shows the compiled pdf, without having to switch to the root-file editor. I did test it a bit (on Linux only though), however since I didn't know the codebase at all before doing the change, I don't know whether I missed something.
Note: Today I discovered that this does not work yet when you just created the project. However, after restarting Gummi and opening the project via "Project -> Open Project" the preview functionality works as intended. |
Would it be possible for you to produce a version of this patch that applies to the GTK3 port of Gummi (non-official)? This is probably not where I should ask this, but I'm new to github. How do I apply this patch using Ubuntu to the version of gummi I can download from here? |
I'm quite busy these days, however I'll try to find some time to look into this in the next few days. I don't know how much of the codebase changed, so it's either directly applicable or I need to rewrite some stuff. I'll let you know once I know more. |
@@ -174,7 +174,7 @@ void on_projfile_add_clicked (GtkWidget* widget, void* user) { | |||
int amount = projectgui_list_projfiles (gummi->project->projfile); | |||
gtk_label_set_text (gui->projectgui->proj_nroffiles, | |||
g_strdup_printf("%d", amount)); | |||
gui_open_file (selected); | |||
gui_open_file (selected, NULL, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Root/created editor is not set -- when a new file is added.
This would cause the preview (for newly added files) to use the old behavior of compiling/previewing the current document (instead of the root).
The rooteditor is only set when the project files are loaded (but not when created/added).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would cause the preview to use the old behavior of attemping to compile the current editor/document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following works when the project is newly created.
- get all editors (and find the one that is the root, generally the first one)
- open the added file, and set the created editor's project file
void on_projfile_add_clicked (GtkWidget* widget, void* user) {
gboolean status = FALSE;
gchar* selected = NULL;
gint rootpos;
GuEditor* rootEditor = NULL;
selected = get_open_filename (TYPE_LATEX);
if (selected) {
if (project_add_document (gummi->project->projfile, selected)) {
int amount = projectgui_list_projfiles (gummi->project->projfile);
gtk_label_set_text (gui->projectgui->proj_nroffiles,
g_strdup_printf("%d", amount));
GList* editor_list = gummi_get_all_editors();
gint length = g_list_length (editor_list);
for (int i=0; i<length;i++) {
GuEditor* editor = g_list_nth_data (editor_list, i);
if(strcmp(editor->filename, gummi->project->rootfile) == 0) {
rootEditor = editor;
fprintf(stderr,"Found rootEditor at pos:%d\n", i);
GuEditor* createdEditor = NULL;
gui_open_file (selected, rootEditor, &createdEditor);
createdEditor->projfile = gummi->project->projfile;
rootpos = i;
status = TRUE;
break;
}
}
}
else {
statusbar_set_message ("Error adding document to the project..");
}
}
if (status == TRUE) projectgui_set_rootfile (rootpos);
g_free (selected);
}
This patch aims to fix #13.
When opening a project, each file-editor receives a pointer to the editor
instance of the root file. After saving a non-root file of a project, Gummi will
compile the pdf as if the root file was changed.
Note: This doesn't provide a live-preview for non-root files, but at least it
shows the compiled pdf, without having to switch to the root-file editor.
I did test it a bit (on Linux only though), however since I didn't know the
codebase at all before doing the change, I don't know whether I missed
something.