summaryrefslogtreecommitdiff
path: root/rcm-client-receive.c
diff options
context:
space:
mode:
Diffstat (limited to 'rcm-client-receive.c')
-rw-r--r--rcm-client-receive.c76
1 files changed, 27 insertions, 49 deletions
diff --git a/rcm-client-receive.c b/rcm-client-receive.c
index 9c1646d..c31df5c 100644
--- a/rcm-client-receive.c
+++ b/rcm-client-receive.c
@@ -35,12 +35,6 @@ struct rcbutton {
static struct remote *remote = NULL;
-
-GdkRGBA *remote_background_color;
-GdkRGBA *remote_edit_background_color;
-GdkRGBA *cd;
-GdkRGBA *cb;
-
static void
quick_message(GtkWindow *parent, gchar *message)
{
@@ -80,13 +74,12 @@ button_press_event_cb(GtkButton *button, gpointer user_data)
#define REMOTE_BUTTON_PADDING 2
#define REMOTE_BUTTON_FONT_SIZE 15
-static GtkWidget *
-create_button(const char *keycode)
+static void
+create_button_img(GtkWidget *button, const char *keycode)
{
struct linux_input_keycode *lik;
cairo_surface_t *surface;
cairo_t *ct;
- GtkWidget *button;
cairo_text_extents_t text_extents;
cairo_font_extents_t font_extents;
GtkWidget *img;
@@ -94,6 +87,7 @@ create_button(const char *keycode)
double x, y;
double scale_x, scale_y;
double scale = 1.0;
+ GdkRGBA color;
for (lik = &linux_input_keycodes[0]; lik->name; lik++)
if (keycode && !strcmp(lik->name, keycode))
@@ -111,6 +105,7 @@ create_button(const char *keycode)
REMOTE_BUTTON_WIDTH,
REMOTE_BUTTON_HEIGHT);
ct = cairo_create(surface);
+ /* FIXME: Make this themeable */
cairo_set_font_size(ct, REMOTE_BUTTON_FONT_SIZE);
cairo_text_extents(ct, label, &text_extents);
/* font extents so the vertial alignment is the same for all buttons */
@@ -123,7 +118,10 @@ create_button(const char *keycode)
y = REMOTE_BUTTON_HEIGHT / 2 - (font_extents.descent - font_extents.height / 2.0) * scale;
cairo_move_to(ct, x, y);
cairo_scale(ct, scale, scale);
- cairo_set_source_rgb(ct, 0.1, 0.1, 0.1);
+ gtk_style_context_get_color(gtk_widget_get_style_context(button),
+ gtk_widget_get_state_flags(button),
+ &color);
+ gdk_cairo_set_source_rgba(ct, &color);
cairo_show_text(ct, label);
cairo_destroy(ct);
@@ -131,10 +129,7 @@ create_button(const char *keycode)
out:
img = gtk_image_new_from_surface(lik->cs);
- button = gtk_button_new();
gtk_button_set_image(GTK_BUTTON(button), img);
-
- return button;
}
static struct rcbutton *
@@ -149,10 +144,11 @@ new_button_add(GtkGrid *grid, const char *name, GdkRGBA *color,
rcb->row = y;
rcb->cols = w;
rcb->rows = h;
- rcb->button = create_button(name);
+ rcb->button = gtk_button_new();
g_signal_connect(rcb->button, "clicked", G_CALLBACK(button_press_event_cb), rcb);
remote->buttons = g_list_append(remote->buttons, rcb);
gtk_grid_attach(grid, rcb->button, x, y, w, h);
+ create_button_img(rcb->button, name);
return rcb;
}
@@ -296,8 +292,6 @@ on_notebook_page_change(GtkNotebook *notebook, GtkWidget *page, guint new_page_n
void rcng_client_receive_init_ui(GDBusObject *new_hw)
{
- GtkStateFlags state;
- GtkStyleContext *style_context;
static bool first = true;
if (first) {
@@ -336,32 +330,30 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw)
gsize n_items;
GVariant *item;
- style_context = gtk_widget_get_style_context(GTK_WIDGET(global->window));
- state = gtk_widget_get_state_flags(GTK_WIDGET(global->window));
- gtk_style_context_get(style_context, state, "background-color",
- &remote_background_color, NULL);
-
- remote_edit_background_color = gdk_rgba_copy(remote_background_color);
- remote_edit_background_color->green *= 1.5;
-
- cd = gdk_rgba_copy(remote_background_color);
- cd->red *= 0.7;
- cd->green *= 0.7;
- cd->blue *= 0.7;
-
- cb = gdk_rgba_copy(remote_background_color);
- cb->red = 0.0;
- cb->green = 0.0;
- cb->blue = 0.0;
- cb->alpha = 1.0;
-
n_items = g_variant_iter_init(&iter, km_entries);
g_print("Key items: %zu\n", n_items);
guint row = 0;
guint col = 0;
+ scrollda = gtk_scrolled_window_new(NULL, NULL);
+ own_page_num = gtk_notebook_append_page(global->notebook, scrollda, gtk_label_new("Receive"));
+
+ GtkWidget *fixed;
+ fixed = gtk_fixed_new();
+ gtk_container_add(GTK_CONTAINER(scrollda), fixed);
+
+ 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);
+
GtkWidget *grid;
grid = gtk_grid_new();
+ gtk_container_add(GTK_CONTAINER(frame), grid);
gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
gtk_grid_set_row_spacing(GTK_GRID(grid), 12);
gtk_grid_set_column_homogeneous(GTK_GRID(grid), true);
@@ -388,20 +380,6 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw)
printf("Got a key: %s:0x%08" PRIx64 ":%s\n", protocol, scancode, keycode);
}
-
- scrollda = gtk_scrolled_window_new(NULL, NULL);
-
- GtkWidget *frame;
- frame = gtk_frame_new(NULL);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_widget_override_background_color(GTK_WIDGET(frame), GTK_STATE_FLAG_NORMAL, cd);
- G_GNUC_END_IGNORE_DEPRECATIONS
- gtk_container_set_border_width(GTK_CONTAINER(frame), 12);
- gtk_container_add(GTK_CONTAINER(frame), grid);
-
- gtk_container_add(GTK_CONTAINER(scrollda), frame);
gtk_widget_show_all(scrollda);
- own_page_num = gtk_notebook_append_page(global->notebook, scrollda, gtk_label_new("Receive"));
}