mirror of
https://github.com/Geronymos/desktop-icons
synced 2024-11-22 10:05:50 +01:00
open default app for file on double click
This commit is contained in:
parent
ceadebf005
commit
9e35e33ede
75
dicons.c
75
dicons.c
|
@ -60,57 +60,31 @@ static GtkListStore *create_desktop_list(void)
|
||||||
return GTK_LIST_STORE(store);
|
return GTK_LIST_STORE(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static void setup_listitem_cb(GtkListItemFactory *factory, GtkListItem *list_item)
|
static void activate_cb(GtkIconView *icon_view, GtkTreePath *tree_path, gpointer user_data)
|
||||||
// {
|
{
|
||||||
// GtkWidget *box;
|
GtkListStore *store;
|
||||||
// GtkWidget *image;
|
GtkTreeIter iter;
|
||||||
// GtkWidget *label;
|
GFile *file;
|
||||||
//
|
char* file_uri;
|
||||||
// box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
|
store = GTK_LIST_STORE (user_data);
|
||||||
// image = gtk_image_new();
|
|
||||||
// gtk_image_set_icon_size(GTK_IMAGE(image), GTK_ICON_SIZE_LARGE);
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (store),
|
||||||
// gtk_box_append(GTK_BOX(box), image);
|
&iter, tree_path);
|
||||||
// label = gtk_label_new("");
|
|
||||||
// gtk_box_append(GTK_BOX(box), label);
|
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
|
||||||
// gtk_list_item_set_child(list_item, box);
|
COL_FILE, &file,
|
||||||
// }
|
-1);
|
||||||
//
|
|
||||||
// static void bind_listitem_cb(GtkListItemFactory *factory, GtkListItem *list_item)
|
file_uri = g_file_get_uri(file);
|
||||||
// {
|
printf("uri %s\n", file_uri);
|
||||||
// GtkWidget *image;
|
|
||||||
// GtkWidget *label;
|
g_app_info_launch_default_for_uri(file_uri, 0, 0);
|
||||||
// GFile *file;
|
}
|
||||||
// GFileInfo *file_info;
|
|
||||||
//
|
|
||||||
// image = gtk_widget_get_first_child(gtk_list_item_get_child(list_item));
|
|
||||||
// label = gtk_widget_get_next_sibling(image);
|
|
||||||
// file = gtk_list_item_get_item(list_item);
|
|
||||||
// file_info = g_file_query_info(file, "standard::*,ownser::user", 0, 0, 0);
|
|
||||||
//
|
|
||||||
// gtk_image_set_from_gicon(GTK_IMAGE(image), g_file_info_get_icon(file_info));
|
|
||||||
// gtk_label_set_label(GTK_LABEL(label), g_file_info_get_display_name(file_info));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// static void activate_cb(GtkGridView *list, guint position, gpointer unused)
|
|
||||||
// {
|
|
||||||
// GdkAppLaunchContext *context;
|
|
||||||
// GFile *file;
|
|
||||||
// char* file_uri = g_file_get_uri(file);
|
|
||||||
//
|
|
||||||
// file = g_list_model_get_item(G_LIST_MODEL(gtk_grid_view_get_model(list)), position);
|
|
||||||
// printf("uri %s\n", file_uri);
|
|
||||||
//
|
|
||||||
// g_app_info_launch_default_for_uri(file_uri, 0, 0);
|
|
||||||
//
|
|
||||||
// g_object_unref(file);
|
|
||||||
// }
|
|
||||||
|
|
||||||
static void activate (GtkApplication* app, gpointer user_data)
|
static void activate (GtkApplication* app, gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget *window, *icon_view;
|
GtkWidget *window, *icon_view;
|
||||||
// , *gridview;
|
|
||||||
GtkListStore *model;
|
GtkListStore *model;
|
||||||
// GtkListItemFactory *factory;
|
|
||||||
|
|
||||||
window = gtk_application_window_new(app);
|
window = gtk_application_window_new(app);
|
||||||
gtk_window_set_title(GTK_WINDOW (window), "Window");
|
gtk_window_set_title(GTK_WINDOW (window), "Window");
|
||||||
|
@ -119,10 +93,6 @@ static void activate (GtkApplication* app, gpointer user_data)
|
||||||
gtk_layer_init_for_window(GTK_WINDOW(window));
|
gtk_layer_init_for_window(GTK_WINDOW(window));
|
||||||
gtk_layer_set_layer(GTK_WINDOW(window), GTK_LAYER_SHELL_LAYER_BOTTOM);
|
gtk_layer_set_layer(GTK_WINDOW(window), GTK_LAYER_SHELL_LAYER_BOTTOM);
|
||||||
|
|
||||||
// factory = gtk_signal_list_item_factory_new();
|
|
||||||
// g_signal_connect(factory, "setup", G_CALLBACK(setup_listitem_cb), NULL);
|
|
||||||
// g_signal_connect(factory, "bind", G_CALLBACK(bind_listitem_cb), NULL);
|
|
||||||
|
|
||||||
model = create_desktop_list();
|
model = create_desktop_list();
|
||||||
icon_view = gtk_icon_view_new_with_model(GTK_TREE_MODEL(model));
|
icon_view = gtk_icon_view_new_with_model(GTK_TREE_MODEL(model));
|
||||||
|
|
||||||
|
@ -130,15 +100,12 @@ static void activate (GtkApplication* app, gpointer user_data)
|
||||||
GTK_SELECTION_MULTIPLE);
|
GTK_SELECTION_MULTIPLE);
|
||||||
gtk_icon_view_set_text_column(GTK_ICON_VIEW (icon_view), COL_DISPLAY_NAME);
|
gtk_icon_view_set_text_column(GTK_ICON_VIEW (icon_view), COL_DISPLAY_NAME);
|
||||||
gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW (icon_view), COL_PIXBUF);
|
gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW (icon_view), COL_PIXBUF);
|
||||||
// gridview = gtk_grid_view_new(GTK_SELECTION_MODEL(gtk_single_selection_new(model)), factory);
|
|
||||||
|
|
||||||
// g_signal_connect(gridview, "activate", G_CALLBACK(activate_cb), NULL);
|
g_signal_connect(icon_view, "item-activated", G_CALLBACK(activate_cb), model);
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(window), icon_view);
|
gtk_container_add(GTK_CONTAINER(window), icon_view);
|
||||||
gtk_widget_grab_focus (icon_view);
|
gtk_widget_grab_focus (icon_view);
|
||||||
|
|
||||||
// gtk_window_present(GTK_WINDOW (window));
|
|
||||||
|
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue