diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app.h | 10 | ||||
-rw-r--r-- | src/main.c | 62 | ||||
-rw-r--r-- | src/selmgr.c | 56 |
3 files changed, 65 insertions, 63 deletions
@@ -36,20 +36,22 @@ struct thread_data { }; +/* main.c */ +extern unsigned timestamp; + /* selmon.c */ int sel_monitor_init(struct thread_data *data); -/* selman.c */ +/* selmgr.c */ int sel_manager_init(struct thread_data *data); void -expose(xcb_atom_t atom, xcb_window_t owner, security_context_t level, - xcb_timestamp_t time); +sel_expose(GtkWidget *widget, GtkTreeView *view); void -expose_stop(xcb_timestamp_t time); +sel_expose_stop(GtkDialog *dialog, gint response_id, gpointer user_data); /* propmon.c */ int @@ -11,7 +11,8 @@ static GtkWidget *appwin; static GtkWidget *expwin; static GtkListStore *sel_store; static GtkTreeStore *prop_store, *dev_store; -static unsigned timestamp; +static GtkTreeView *sel_view; +unsigned timestamp; static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) @@ -41,58 +42,6 @@ event_register(GObject *obj) g_signal_connect(obj, "button-release-event", G_CALLBACK(event), NULL); } -static void -start(GtkWidget *widget, GtkTreeView *tree) -{ - GtkTreeSelection *sel; - GtkTreeIter iter; - GtkWidget *dialog; - xcb_atom_t atom; - xcb_window_t owner; - gchar *name, *octx; - - sel = gtk_tree_view_get_selection(tree); - - if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { - gtk_tree_model_get(GTK_TREE_MODEL(sel_store), &iter, - COL_ATOM, &atom, COL_WIN, &owner, - COL_NAME, &name, COL_OCTX, &octx, - -1); - - dialog = gtk_message_dialog_new(GTK_WINDOW(appwin), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - "Really make clipboard %s,\n" - "at level %s\n" - "available to all levels?", - name, octx); - - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES) - expose(atom, owner, octx, timestamp); - - gtk_widget_destroy(dialog); - g_free(name); - g_free(octx); - } - else { - dialog = gtk_message_dialog_new(GTK_WINDOW(appwin), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "No clipboard is currently selected."); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - } -} - -static void -stop(GtkDialog *dialog, gint response_id, gpointer user_data) -{ - gtk_widget_hide_all(expwin); - expose_stop(timestamp); -} - static GtkWidget * create_sel_widget(void) { @@ -152,6 +101,7 @@ create_sel_widget(void) gtk_tree_view_append_column(tree, column); sel_store = store; + sel_view = tree; return GTK_WIDGET(tree); } @@ -324,7 +274,7 @@ create_dialogs(void) box = gtk_dialog_get_content_area(GTK_DIALOG(expwin)); gtk_box_pack_start(GTK_BOX(box), scroll, TRUE, TRUE, 0); - g_signal_connect(G_OBJECT(expwin), "response", G_CALLBACK(stop), NULL); + g_signal_connect(G_OBJECT(expwin), "response", G_CALLBACK(sel_expose_stop), NULL); } @@ -346,17 +296,15 @@ create_menu(void) gtk_menu_shell_append(GTK_MENU_SHELL(bar), item); /* Action menu */ -/* menu = gtk_menu_new(); item = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, NULL); event_register(G_OBJECT(item)); - g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(start), selw); + g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(sel_expose), sel_view); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); item = gtk_menu_item_new_with_mnemonic("_Action"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu); gtk_menu_shell_append(GTK_MENU_SHELL(bar), item); -*/ return bar; } diff --git a/src/selmgr.c b/src/selmgr.c index 7ac4a95..490163d 100644 --- a/src/selmgr.c +++ b/src/selmgr.c @@ -69,7 +69,7 @@ setup_x(const gchar *display) xcb_flush(conn); } -void +static void expose_stop(xcb_timestamp_t time) { security_context_t octx; @@ -121,7 +121,7 @@ expose_item_matches(GtkTreeIter *iter, xcb_atom_t name, security_context_t ctx) return result; } -void +static void expose(xcb_atom_t name, xcb_window_t owner, security_context_t level, xcb_timestamp_t time) { @@ -479,3 +479,55 @@ sel_manager_init(struct thread_data *data) return 0; } + +void +sel_expose(GtkWidget *widget, GtkTreeView *view) +{ + GtkTreeSelection *sel; + GtkTreeIter iter; + GtkWidget *dialog; + xcb_atom_t atom; + xcb_window_t owner; + gchar *name, *octx; + + sel = gtk_tree_view_get_selection(view); + + if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, + COL_ATOM, &atom, COL_WIN, &owner, + COL_NAME, &name, COL_OCTX, &octx, + -1); + + dialog = gtk_message_dialog_new(GTK_WINDOW(appwin), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + "Really make clipboard %s,\n" + "at level %s\n" + "available to all levels?", + name, octx); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES) + expose(atom, owner, octx, timestamp); + + gtk_widget_destroy(dialog); + g_free(name); + g_free(octx); + } + else { + dialog = gtk_message_dialog_new(GTK_WINDOW(appwin), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "No clipboard is currently selected."); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + } +} + +void +sel_expose_stop(GtkDialog *dialog, gint response_id, gpointer user_data) +{ + gtk_widget_hide_all(expwin); + expose_stop(timestamp); +} |