summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-07-30 23:12:56 +0200
committerDavid Härdeman <david@hardeman.nu>2015-07-30 23:12:56 +0200
commitb9b87e3cc82e0e52372ea8b1c04416e6356bef7b (patch)
tree915eb0d2692a7f630e5c8dd5cf937e1133ddc7ea
parentcf94c763b15d7fc98d5e3f16ddbfcd8b79b99536 (diff)
Preliminary work to reduce number of notebook tabs
-rw-r--r--rcm-client-receive.c34
-rw-r--r--rcm-server-main.c2
2 files changed, 28 insertions, 8 deletions
diff --git a/rcm-client-receive.c b/rcm-client-receive.c
index 0720535..ee8c941 100644
--- a/rcm-client-receive.c
+++ b/rcm-client-receive.c
@@ -54,6 +54,8 @@ struct state {
GList *header_buttons;
bool editing;
bool active;
+ GtkWidget *stack;
+ GtkWidget *stack_switch;
};
static struct state state;
@@ -409,14 +411,17 @@ new_button_add(struct remote *remote, const gchar *protocol, guint64 scancode,
return rcb;
}
-static GtkWidget *scrollda = NULL;
-
void rcng_client_receive_destroy_ui()
{
- if (scrollda)
- gtk_widget_destroy(scrollda);
+ if (state.stack_switch)
+ gtk_widget_destroy(state.stack_switch);
+
+ if (state.stack)
+ gtk_widget_destroy(state.stack);
- scrollda = NULL;
+ g_object_unref(state.stack_switch);
+ state.stack_switch = NULL;
+ state.stack = NULL;
}
static gint own_page_num = -1;
@@ -447,6 +452,7 @@ remove_header_buttons(void)
g_list_free(state.header_buttons);
state.header_buttons = NULL;
+ gtk_header_bar_set_custom_title(GTK_HEADER_BAR(global->header), NULL);
}
static void toggle_edit_keymap(GtkButton *button, gpointer user_data);
@@ -789,6 +795,7 @@ on_notebook_page_change(GtkNotebook *notebook, GtkWidget *page, guint new_page_n
state.editing = false;
set_edit_keymap(state.editing);
g_print("Page change: %i -> %u\n", own_page_num, new_page_num);
+ gtk_header_bar_set_custom_title(GTK_HEADER_BAR(global->header), state.stack_switch);
}
void rcng_client_receive_key_pressed(GDBusObject *obj, const gchar *protocol,
@@ -1000,9 +1007,22 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw)
rcng_client_receive_destroy_ui();
+ GtkWidget *scrollda;
+ GtkWidget *label;
+
+ state.stack = gtk_stack_new();
+ state.stack_switch = gtk_stack_switcher_new();
+ g_object_ref(state.stack_switch);
+ gtk_stack_switcher_set_stack(GTK_STACK_SWITCHER(state.stack_switch), GTK_STACK(state.stack));
+ gtk_widget_show_all(state.stack_switch);
+
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"));
+ gtk_stack_add_titled(GTK_STACK(state.stack), scrollda, "Receive", "Receive");
+ own_page_num = gtk_notebook_append_page(global->notebook, state.stack, gtk_label_new("Receive"));
+
+ label = gtk_label_new("Transmit");
+ gtk_stack_add_titled(GTK_STACK(state.stack), label, "Transmit", "Transmit");
GtkWidget *rgrid;
rgrid = gtk_grid_new();
@@ -1031,6 +1051,6 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw)
}
g_free(keymap_ids);
- gtk_widget_show_all(scrollda);
+ gtk_widget_show_all(state.stack);
}
diff --git a/rcm-server-main.c b/rcm-server-main.c
index 990a964..28a1ff0 100644
--- a/rcm-server-main.c
+++ b/rcm-server-main.c
@@ -783,7 +783,7 @@ evdev_read(sd_event_source *s, int fd, uint32_t revents, void *userdata)
/* FIXME: protocol reporting needs kernel support */
if (scancode_recv)
- protocol = evdev_guess_protocol(device, scancode, lik ? lik->value : KEY_RESERVED);
+ protocol = evdev_guess_protocol(device, scancode, keycode ? keycode->value : KEY_RESERVED);
printf("evdev -");