Move code to launch the external editor to own function
This commit is contained in:
parent
99e3de70b9
commit
92b75f526d
@ -780,6 +780,27 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief mainWindow_openExternalEditor opens the supplied path with the default system editor
|
||||||
|
* @param mainWindow
|
||||||
|
* @param path is the file to open
|
||||||
|
*/
|
||||||
|
void mainWindow_openExternalEditor(gchar *path)
|
||||||
|
{
|
||||||
|
GFile *file;
|
||||||
|
GAppInfo *info;
|
||||||
|
GList *files = NULL;
|
||||||
|
|
||||||
|
g_info("Opening entry in external editor.");
|
||||||
|
file = g_file_new_for_path(path);
|
||||||
|
info = g_file_query_default_handler(file, NULL, NULL);
|
||||||
|
files = g_list_append(files, (gpointer) file);
|
||||||
|
g_app_info_launch(info, files, NULL, NULL);
|
||||||
|
g_list_free(files); // Content is freed individually
|
||||||
|
g_object_unref(info);
|
||||||
|
g_object_unref(file);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief mainWindow_entryActivated is the callback when the user doubleclicks or presses enter on an entry
|
* @brief mainWindow_entryActivated is the callback when the user doubleclicks or presses enter on an entry
|
||||||
* @param widget is the entryListView
|
* @param widget is the entryListView
|
||||||
@ -787,9 +808,7 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
|
|||||||
*/
|
*/
|
||||||
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
|
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
|
||||||
{
|
{
|
||||||
GFile *file;
|
|
||||||
GAppInfo *info;
|
|
||||||
GList *files = NULL;
|
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeView *treeview = (GtkTreeView*) widget;
|
GtkTreeView *treeview = (GtkTreeView*) widget;
|
||||||
@ -798,16 +817,9 @@ void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeView
|
|||||||
model = gtk_tree_view_get_model(treeview);
|
model = gtk_tree_view_get_model(treeview);
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter(model, &iter, path)) {
|
if (gtk_tree_model_get_iter(model, &iter, path)) {
|
||||||
g_info("Opening entry in external editor.");
|
|
||||||
gtk_tree_model_get(model, &iter, COL_URL, &name, -1);
|
gtk_tree_model_get(model, &iter, COL_URL, &name, -1);
|
||||||
file = g_file_new_for_path(name);
|
mainWindow_openExternalEditor(name);
|
||||||
info = g_file_query_default_handler(file, NULL, NULL);
|
|
||||||
files = g_list_append(files, (gpointer) file);
|
|
||||||
g_app_info_launch(info, files, NULL, NULL);
|
|
||||||
g_free(name);
|
g_free(name);
|
||||||
g_list_free(files); // Content is freed individually
|
|
||||||
g_object_unref(info);
|
|
||||||
g_object_unref(file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ void mainWindow_workspaceListClicked(GtkWidget *widget,
|
|||||||
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data);
|
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
|
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
|
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
|
||||||
|
void mainWindow_openExternalEditor(gchar *path);
|
||||||
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data);
|
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data);
|
||||||
void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);
|
void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_workspace_search_changed(GtkWidget *widget, gpointer user_data);
|
void mainWindow_workspace_search_changed(GtkWidget *widget, gpointer user_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user