summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-08-13 00:00:50 +0200
committerDavid Härdeman <david@hardeman.nu>2015-08-13 00:00:50 +0200
commit4ff99499ccfd3c66934217a3f5ac32676abdfda8 (patch)
tree4c542748da719e7f3a6caa809e9dc807bb0dedd6
parent62c858892193b6dc7ae7f0adefe043f094d74cb6 (diff)
Add basic gtk_builder support
-rw-r--r--rcm-client-main.c34
-rw-r--r--rcm-client-main.h1
-rw-r--r--rcm-client.ui35
3 files changed, 42 insertions, 28 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.19.0 -->
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <object class="GtkWindow" id="main_window">
+ <property name="name">RemoteControlClientWindow</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">gnome-multimedia</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="headerbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title">Remote Control Configuration</property>
+ <property name="has_subtitle">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="main_stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <property name="transition_type">crossfade</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>