Add doubleclick-to-open feature (Resolves #2)

This commit is contained in:
Markus Koch 2017-07-07 20:51:33 +02:00
parent 84398e7be7
commit 2b2d7d08e3
2 changed files with 37 additions and 0 deletions

View File

@ -337,6 +337,11 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
(GCallback) mainWindow_entrySelected,
mainWindow);
g_signal_connect(mainWindow->entryListView,
"row-activated",
(GCallback) mainWindow_entryActivated,
mainWindow);
g_signal_connect(mainWindow->dateStart,
"changed",
(GCallback) mainWindow_filterChanged,
@ -768,6 +773,37 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
}
}
/**
* @brief mainWindow_entryActivated is the callback when the user doubleclicks or presses enter on an entry
* @param widget is the entryListView
* @param user_data struct mainWindow *
*/
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
{
GFile *file;
GAppInfo *info;
GList *files = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeView *treeview = (GtkTreeView*) widget;
gchar *name;
model = gtk_tree_view_get_model(treeview);
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);
file = g_file_new_for_path(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_list_free(files); // Content is freed individually
g_object_unref(info);
g_object_unref(file);
}
}
/**
* @brief mainWindow_filterChanged updates the filter backend values
* @param widget The widget that caused the update request. Can be NULL to update all.

View File

@ -98,6 +98,7 @@ void mainWindow_workspaceListClicked(GtkWidget *widget,
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data);
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
void mainWindow_entrySelected(GtkWidget *widget, 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_workspace_search_changed(GtkWidget *widget, gpointer user_data);
void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data);