From 6ded25de2b1d9f980dc24ecb5716b034d4f79c41 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Sat, 21 Jul 2007 23:04:24 +0100 Subject: [PATCH] Added a primitive launch awareness to the gui, this is dirty and just a way to test things. --- src/gui.c | 35 +++++++++++++++++++++++++++++++++++ src/main.c | 2 +- src/plugins/console.c | 2 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/gui.c b/src/gui.c index a26c76b..dfb1b8b 100644 --- a/src/gui.c +++ b/src/gui.c @@ -47,6 +47,10 @@ static void _gui_add_item (gpointer data, gpointer userdata) GtkListStore *pTreeStore = GTK_LIST_STORE (gtk_tree_view_get_model(GTK_TREE_VIEW(gResultsTable))); GtkTreeIter iter; + GSList *list = (GSList*)g_object_get_data (G_OBJECT(pTreeStore), "private-list"); + list = g_slist_append (list, data); + g_object_set_data (G_OBJECT(pTreeStore), "private-list", list); + gtk_list_store_append (pTreeStore, &iter); gtk_list_store_set (pTreeStore, &iter, COL_RESULT, action->text, @@ -71,6 +75,34 @@ static void _gui_search (GtkButton *pButton, gpointer data) } } +static gboolean _gui_tree_view_event_handler (GtkWidget* widget, GdkEventButton* event, gpointer data) +{ + switch (event->type) + { + case GDK_2BUTTON_PRESS: + { + GtkTreePath *path; + GtkTreeIter iter; + GtkTreeModel *pTreeModel = gtk_tree_view_get_model(GTK_TREE_VIEW(gResultsTable)); + + g_print ("double click %.2f, %.2f\n",event->x, event->y); + if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(widget), (gint)event->x, (gint)event->y, &path, NULL, NULL, NULL)) + { + gint *ind = gtk_tree_path_get_indices (path); + gchar* text; + GSList *list = (GSList*)g_object_get_data (G_OBJECT(pTreeModel), "private-list"); + text = ((TeleportAction*)(g_slist_nth_data (list,ind[0])))->text; + g_print ("%s\n",text); + } + + + break; + } + } + + return FALSE; +} + static void _gui_init_tree_view () { GtkCellRenderer *pCellRenderer; @@ -84,6 +116,9 @@ static void _gui_init_tree_view () pTreeStore = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING); gtk_tree_view_set_model (GTK_TREE_VIEW (gResultsTable), GTK_TREE_MODEL(pTreeStore)); + + gtk_widget_add_events (GTK_WIDGET (gResultsTable), GDK_BUTTON_PRESS); + g_signal_connect (G_OBJECT (gResultsTable), "button_press_event", G_CALLBACK(_gui_tree_view_event_handler), NULL); } static gboolean _gui_quit (GtkWidget *widget, gpointer data) diff --git a/src/main.c b/src/main.c index 73e121d..f50db35 100644 --- a/src/main.c +++ b/src/main.c @@ -28,7 +28,7 @@ int main (int argc, char *argv[]) _gui_init (&argc, &argv); teleport_load_plugin ("console"); - teleport_load_plugin ("tracker"); +/* teleport_load_plugin ("tracker"); */ teleport_load_plugin ("beagleplugin"); teleport_init_main_loop (); diff --git a/src/plugins/console.c b/src/plugins/console.c index 9309ccd..1523ac4 100644 --- a/src/plugins/console.c +++ b/src/plugins/console.c @@ -21,6 +21,7 @@ **/ #include "teleport.h" +#define CONSOLE_PROGRAM "gnome-terminal" static GSList* console_query (const TeleportPlugin *plug, const gchar* term) @@ -47,6 +48,7 @@ GSList* console_query (const TeleportPlugin *plug, const gchar* term) static gboolean console_do_action (TeleportAction *act) { + g_print ("Trying to execute %s\n",act->text); return FALSE; } -- 2.11.4.GIT