From 4ff99499ccfd3c66934217a3f5ac32676abdfda8 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 13 Aug 2015 00:00:50 +0200 Subject: Add basic gtk_builder support --- rcm-client-main.c | 34 ++++++---------------------------- rcm-client-main.h | 1 + rcm-client.ui | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 rcm-client.ui diff --git a/rcm-client-main.c b/rcm-client-main.c index 27862fa..54bf490 100644 --- a/rcm-client-main.c +++ b/rcm-client-main.c @@ -159,14 +159,15 @@ int main (int argc, char *argv[]) gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref(css); + global->builder = gtk_builder_new_from_file("rcm-client.ui"); + object_manager_client_new_for_bus(G_BUS_TYPE_SESSION, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "org.gnome.RemoteControlManager", "/org/gnome/RemoteControlManager", NULL, manager_ready_cb, NULL); - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_set_name(win, "RemoteControlClientWindow"); + win = GTK_WIDGET(gtk_builder_get_object(global->builder, "main_window")); global->window = GTK_WINDOW(win); g_signal_connect(win, "destroy", G_CALLBACK (gtk_main_quit), NULL); @@ -176,36 +177,13 @@ int main (int argc, char *argv[]) rect.width * 4 / 5, rect.height * 1 / 2); - global->header = GTK_HEADER_BAR(gtk_header_bar_new()); - gtk_header_bar_set_title(global->header, "Remote Control Configuration"); - gtk_header_bar_set_has_subtitle(global->header, FALSE); + global->header = GTK_HEADER_BAR(gtk_builder_get_object(global->builder, "headerbar")); gtk_header_bar_set_show_close_button(global->header, TRUE); - gtk_window_set_titlebar(global->window, GTK_WIDGET(global->header)); - - /* - GtkWidget *label; - label = gtk_label_new("Pack Start"); - gtk_header_bar_pack_start(GTK_HEADER_BAR(header), label); - label = gtk_label_new("Pack End"); - gtk_header_bar_pack_end(GTK_HEADER_BAR(header), label); - GtkWidget *test = gtk_button_new_from_icon_name("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_button_set_label(GTK_BUTTON(test), "Test"); - gtk_button_set_always_show_image(GTK_BUTTON(test), TRUE); - gtk_header_bar_pack_end(GTK_HEADER_BAR(header), test); - */ - - global->stack = GTK_STACK(gtk_stack_new()); - gtk_widget_set_margin_start(GTK_WIDGET(global->stack), 12); - gtk_widget_set_margin_end(GTK_WIDGET(global->stack), 12); - gtk_widget_set_margin_top(GTK_WIDGET(global->stack), 12); - gtk_widget_set_margin_bottom(GTK_WIDGET(global->stack), 12); - gtk_stack_set_transition_type(global->stack, GTK_STACK_TRANSITION_TYPE_CROSSFADE); + + global->stack = GTK_STACK(gtk_builder_get_object(global->builder, "main_stack")); rcng_client_hardware_list_init_ui(); - gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(global->stack)); - //gtk_window_set_title(window, "Remote Control Configuration"); - gtk_window_set_icon_name(global->window, "gnome-multimedia"); gtk_widget_show_all(win); gtk_main(); diff --git a/rcm-client-main.h b/rcm-client-main.h index 2b1461f..9107273 100644 --- a/rcm-client-main.h +++ b/rcm-client-main.h @@ -4,6 +4,7 @@ struct global_variables { GtkWindow *window; GtkHeaderBar *header; GtkStack *stack; + GtkBuilder *builder; }; extern struct global_variables *global; diff --git a/rcm-client.ui b/rcm-client.ui new file mode 100644 index 0000000..c7bfd51 --- /dev/null +++ b/rcm-client.ui @@ -0,0 +1,35 @@ + + + + + + RemoteControlClientWindow + False + gnome-multimedia + + + True + False + Remote Control Configuration + False + + + + + + + + True + False + 12 + 12 + 12 + 12 + crossfade + + + + + + + -- cgit v1.2.3