summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-07-15 16:01:10 +0200
committerDavid Härdeman <david@hardeman.nu>2015-07-15 16:01:10 +0200
commit9c9f384b8e71382b3b5e33a5ffc56b50b70c0d9a (patch)
tree0e96dcb940ab2673c2a1d26b6634582dcc430a14
parent944ffc1a1f1bae8812ee4d0ddda786aea09bb617 (diff)
Refactor remote drawing a bit
Most importantly, use GtkToggleButton for the buttons since the server will indicate when the buttons are pressed/released for RX.
-rw-r--r--rcm-client-receive.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/rcm-client-receive.c b/rcm-client-receive.c
index 3dd7f20..4ce3056 100644
--- a/rcm-client-receive.c
+++ b/rcm-client-receive.c
@@ -35,6 +35,7 @@ struct rcbutton {
static struct remote *remote = NULL;
+#if 0
static void
quick_message(GtkWindow *parent, gchar *message)
{
@@ -51,23 +52,7 @@ quick_message(GtkWindow *parent, gchar *message)
gtk_container_add(GTK_CONTAINER(content_area), label);
gtk_widget_show_all(dialog);
}
-
-static void
-button_press_event_cb(GtkButton *button, gpointer user_data)
-{
- struct rcbutton *rcb = user_data;
-
- if (GTK_BUTTON(rcb->button) != button)
- return;
-
- if (remote->editing) {
- printf("Button at %ux%u clicked in edit mode\n", rcb->col, rcb->row);
- quick_message(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))), "Edit button pressed");
- } else {
- printf("Button at %ux%u clicked\n", rcb->col, rcb->row);
- poke_objects();
- }
-}
+#endif
/* Hacky McHack - Estimate the size needed for a button with ABCDEF */
static int
@@ -186,8 +171,8 @@ new_button_add(GtkGrid *grid, const char *name, GdkRGBA *color,
rcb->row = y;
rcb->cols = w;
rcb->rows = h;
- rcb->button = gtk_button_new();
- g_signal_connect(rcb->button, "clicked", G_CALLBACK(button_press_event_cb), rcb);
+ rcb->button = gtk_toggle_button_new();
+ gtk_widget_set_sensitive(rcb->button, false);
remote->buttons = g_list_append(remote->buttons, rcb);
gtk_grid_attach(grid, rcb->button, x, y, w, h);
create_button_img(rcb->button, name);
@@ -378,20 +363,25 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw)
guint col = 0;
scrollda = gtk_scrolled_window_new(NULL, NULL);
+ gtk_container_set_border_width(GTK_CONTAINER(scrollda), 12);
own_page_num = gtk_notebook_append_page(global->notebook, scrollda, gtk_label_new("Receive"));
+ GtkWidget *rgrid;
+ rgrid = gtk_grid_new();
+ gtk_widget_set_halign(rgrid, GTK_ALIGN_CENTER);
+ gtk_grid_set_column_spacing(GTK_GRID(rgrid), 12);
+ gtk_grid_set_row_spacing(GTK_GRID(rgrid), 12);
+ gtk_container_add(GTK_CONTAINER(scrollda), rgrid);
+
GtkWidget *fixed;
fixed = gtk_fixed_new();
- gtk_container_add(GTK_CONTAINER(scrollda), fixed);
+ gtk_widget_set_name(fixed, "RemoteControlClientFixed");
+ gtk_grid_attach(GTK_GRID(rgrid), fixed, 1, 1, 1, 1);
GtkWidget *frame;
frame = gtk_frame_new(NULL);
gtk_widget_set_name(frame, "RemoteControlClientRemoteFrame");
- GtkBorder margins;
- gtk_style_context_get_margin(gtk_widget_get_style_context(frame),
- gtk_widget_get_state_flags(frame),
- &margins);
- gtk_fixed_put(GTK_FIXED(fixed), frame, margins.top, margins.left);
+ gtk_fixed_put(GTK_FIXED(fixed), frame, 0, 0);
GtkWidget *grid;
grid = gtk_grid_new();