window: move to builder's ui file
This is way better than programmatically building the entire window interface.
This commit is contained in:
committed by
Erick Pérez Castellanos
parent
c87c0e2ad0
commit
8b955cae19
@@ -22,6 +22,7 @@ EXTRA_DIST= \
|
|||||||
ui/menus.ui \
|
ui/menus.ui \
|
||||||
ui/nav_bar.ui \
|
ui/nav_bar.ui \
|
||||||
ui/new-event.ui \
|
ui/new-event.ui \
|
||||||
|
ui/window.ui \
|
||||||
theme/gtk-styles.css \
|
theme/gtk-styles.css \
|
||||||
$(desktop_in_files) \
|
$(desktop_in_files) \
|
||||||
$(gsettingsschema_in_files)
|
$(gsettingsschema_in_files)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<file alias="menus.ui" compressed="true" preprocess="xml-stripblanks">ui/menus.ui</file>
|
<file alias="menus.ui" compressed="true" preprocess="xml-stripblanks">ui/menus.ui</file>
|
||||||
<file alias="nav_bar.ui" compressed="true" preprocess="xml-stripblanks">ui/nav_bar.ui</file>
|
<file alias="nav_bar.ui" compressed="true" preprocess="xml-stripblanks">ui/nav_bar.ui</file>
|
||||||
<file alias="new-event.ui" compressed="true" preprocess="xml-stripblanks">ui/new-event.ui</file>
|
<file alias="new-event.ui" compressed="true" preprocess="xml-stripblanks">ui/new-event.ui</file>
|
||||||
|
<file alias="window.ui" compressed="true" preprocess="xml-stripblanks">ui/window.ui</file>
|
||||||
<file alias="gtk-styles.css" compressed="true">theme/gtk-styles.css</file>
|
<file alias="gtk-styles.css" compressed="true">theme/gtk-styles.css</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.18.1 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.14"/>
|
||||||
|
<template class="GcalWindow" parent="GtkApplicationWindow">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="window_position">center</property>
|
||||||
|
<property name="default_width">800</property>
|
||||||
|
<property name="default_height">600</property>
|
||||||
|
<property name="show_menubar">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkOverlay" id="views_overlay">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="main_box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSearchBar" id="search_bar">
|
||||||
|
<property name="app_paintable">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="no_show_all">True</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="show_close_button">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid" id="search_entry_grid">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSearchEntry" id="search_entry">
|
||||||
|
<property name="width_request">500</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="primary_icon_name">edit-find-symbolic</property>
|
||||||
|
<property name="primary_icon_activatable">False</property>
|
||||||
|
<property name="primary_icon_sensitive">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStack" id="views_stack">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<property name="transition_duration">250</property>
|
||||||
|
<property name="transition_type">slide-left-right</property>
|
||||||
|
<style>
|
||||||
|
<class name="views"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GcalNavBar" id="nav_bar">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="titlebar">
|
||||||
|
<object class="GtkHeaderBar" id="header_bar">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="show_close_button">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="today_button">
|
||||||
|
<property name="label" translatable="yes">Today</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="title">
|
||||||
|
<object class="GtkStackSwitcher" id="views_switcher">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="stack">views_stack</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkMenuButton" id="menu_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="menu_image">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">open-menu-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkToggleButton" id="search_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="search_button_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">edit-find-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<style>
|
||||||
|
<class name="views"/>
|
||||||
|
</style>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
+24
-97
@@ -67,8 +67,10 @@ typedef struct
|
|||||||
GtkWidget *popover; /* short-lived */
|
GtkWidget *popover; /* short-lived */
|
||||||
|
|
||||||
/* header_bar widets */
|
/* header_bar widets */
|
||||||
GtkWidget *today_button;
|
GtkWidget *menu_button;
|
||||||
|
GtkWidget *search_button;
|
||||||
GtkWidget *search_entry;
|
GtkWidget *search_entry;
|
||||||
|
GtkWidget *today_button;
|
||||||
GtkWidget *views_switcher;
|
GtkWidget *views_switcher;
|
||||||
|
|
||||||
/* day, week, month, year, list, search */
|
/* day, week, month, year, list, search */
|
||||||
@@ -926,6 +928,7 @@ gcal_window_class_init(GcalWindowClass *klass)
|
|||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
widget_class->configure_event = gcal_window_configure_event;
|
widget_class->configure_event = gcal_window_configure_event;
|
||||||
widget_class->window_state_event = gcal_window_state_event;
|
widget_class->window_state_event = gcal_window_state_event;
|
||||||
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/window.ui");
|
||||||
|
|
||||||
g_object_class_install_property (
|
g_object_class_install_property (
|
||||||
object_class,
|
object_class,
|
||||||
@@ -964,6 +967,19 @@ gcal_window_class_init(GcalWindowClass *klass)
|
|||||||
"A weak reference to the app manager object",
|
"A weak reference to the app manager object",
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/* widgets */
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, header_bar);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, main_box);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, menu_button);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, nav_bar);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, search_bar);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, search_button);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, search_entry);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, today_button);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, views_overlay);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, views_stack);
|
||||||
|
gtk_widget_class_bind_template_child_private (widget_class, GcalWindow, views_switcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -982,6 +998,8 @@ gcal_window_init (GcalWindow *self)
|
|||||||
priv->save_geometry_timeout_id = 0;
|
priv->save_geometry_timeout_id = 0;
|
||||||
priv->event_to_delete = NULL;
|
priv->event_to_delete = NULL;
|
||||||
priv->open_edit_dialog = FALSE;
|
priv->open_edit_dialog = FALSE;
|
||||||
|
|
||||||
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -989,10 +1007,7 @@ gcal_window_constructed (GObject *object)
|
|||||||
{
|
{
|
||||||
GcalWindowPrivate *priv;
|
GcalWindowPrivate *priv;
|
||||||
|
|
||||||
GtkWidget *box;
|
|
||||||
GtkWidget *search_button;
|
|
||||||
|
|
||||||
GtkWidget *menu_button;
|
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GMenuModel *winmenu;
|
GMenuModel *winmenu;
|
||||||
|
|
||||||
@@ -1012,34 +1027,14 @@ gcal_window_constructed (GObject *object)
|
|||||||
g_free (clock_format);
|
g_free (clock_format);
|
||||||
g_object_unref (helper_settings);
|
g_object_unref (helper_settings);
|
||||||
|
|
||||||
/* ui construction */
|
|
||||||
priv->main_box = gtk_grid_new ();
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->main_box),
|
|
||||||
GTK_ORIENTATION_VERTICAL);
|
|
||||||
|
|
||||||
/* header_bar */
|
|
||||||
priv->header_bar = gtk_header_bar_new ();
|
|
||||||
|
|
||||||
/* header_bar: new */
|
|
||||||
priv->today_button = gtk_button_new_with_label (_("Today"));
|
|
||||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->header_bar),
|
|
||||||
priv->today_button);
|
|
||||||
|
|
||||||
priv->views_switcher = gtk_stack_switcher_new ();
|
|
||||||
g_object_ref_sink (priv->views_switcher);
|
|
||||||
gtk_header_bar_set_custom_title (GTK_HEADER_BAR (priv->header_bar),
|
|
||||||
priv->views_switcher);
|
|
||||||
|
|
||||||
/* header_bar: menu */
|
/* header_bar: menu */
|
||||||
menu_button = gtk_menu_button_new ();
|
gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (priv->menu_button),
|
||||||
gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (menu_button),
|
|
||||||
TRUE);
|
TRUE);
|
||||||
gtk_button_set_image (
|
gtk_button_set_image (
|
||||||
GTK_BUTTON (menu_button),
|
GTK_BUTTON (priv->menu_button),
|
||||||
gtk_image_new_from_icon_name ("open-menu-symbolic",
|
gtk_image_new_from_icon_name ("open-menu-symbolic",
|
||||||
GTK_ICON_SIZE_MENU));
|
GTK_ICON_SIZE_MENU));
|
||||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header_bar),
|
|
||||||
menu_button);
|
|
||||||
|
|
||||||
builder = gtk_builder_new ();
|
builder = gtk_builder_new ();
|
||||||
gtk_builder_add_from_resource (builder,
|
gtk_builder_add_from_resource (builder,
|
||||||
@@ -1047,76 +1042,18 @@ gcal_window_constructed (GObject *object)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
winmenu = (GMenuModel *)gtk_builder_get_object (builder, "winmenu");
|
winmenu = (GMenuModel *)gtk_builder_get_object (builder, "winmenu");
|
||||||
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button),
|
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->menu_button),
|
||||||
winmenu);
|
winmenu);
|
||||||
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
|
|
||||||
/* header_bar: search */
|
/* search bar */
|
||||||
search_button = gtk_toggle_button_new ();
|
|
||||||
gtk_container_add (
|
|
||||||
GTK_CONTAINER (search_button),
|
|
||||||
gtk_image_new_from_icon_name ("edit-find-symbolic",
|
|
||||||
GTK_ICON_SIZE_MENU));
|
|
||||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header_bar),
|
|
||||||
search_button);
|
|
||||||
|
|
||||||
gtk_header_bar_set_show_close_button (
|
|
||||||
GTK_HEADER_BAR (priv->header_bar),
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
gtk_widget_set_hexpand (priv->header_bar, TRUE);
|
|
||||||
gtk_window_set_titlebar (GTK_WINDOW (object), priv->header_bar);
|
|
||||||
|
|
||||||
/* search_bar */
|
|
||||||
priv->search_entry = gtk_search_entry_new ();
|
|
||||||
g_object_set (priv->search_entry,
|
|
||||||
"width-request", 500,
|
|
||||||
"hexpand", TRUE,
|
|
||||||
"halign", GTK_ALIGN_CENTER,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
box = gtk_grid_new ();
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), priv->search_entry);
|
|
||||||
|
|
||||||
priv->search_bar = gtk_search_bar_new ();
|
|
||||||
gtk_widget_set_no_show_all (priv->search_bar, TRUE);
|
|
||||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (priv->search_bar),
|
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (priv->search_bar),
|
||||||
GTK_ENTRY (priv->search_entry));
|
GTK_ENTRY (priv->search_entry));
|
||||||
gtk_widget_set_hexpand (priv->search_bar, TRUE);
|
g_object_bind_property (priv->search_button, "active",
|
||||||
g_object_bind_property (search_button, "active",
|
|
||||||
priv->search_bar, "search-mode-enabled",
|
priv->search_bar, "search-mode-enabled",
|
||||||
G_BINDING_BIDIRECTIONAL);
|
G_BINDING_BIDIRECTIONAL);
|
||||||
gtk_container_add (GTK_CONTAINER (priv->search_bar), box);
|
|
||||||
gtk_container_add (GTK_CONTAINER (priv->main_box), priv->search_bar);
|
|
||||||
gtk_widget_show_all (box);
|
|
||||||
|
|
||||||
/* overlay */
|
|
||||||
priv->views_overlay = gtk_overlay_new ();
|
|
||||||
gtk_container_add (GTK_CONTAINER (priv->main_box), priv->views_overlay);
|
|
||||||
|
|
||||||
box = gtk_grid_new ();
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
|
|
||||||
GTK_ORIENTATION_VERTICAL);
|
|
||||||
gtk_container_add (GTK_CONTAINER (priv->views_overlay), box);
|
|
||||||
|
|
||||||
/* nav_bar */
|
|
||||||
priv->nav_bar = gcal_nav_bar_new ();
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), priv->nav_bar);
|
|
||||||
|
|
||||||
/* stack widget for holding views */
|
|
||||||
priv->views_stack = gtk_stack_new ();
|
|
||||||
g_object_set (priv->views_stack,
|
|
||||||
"vexpand", TRUE,
|
|
||||||
"hexpand", TRUE,
|
|
||||||
"transition-type", GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT,
|
|
||||||
"transition-duration", 250,
|
|
||||||
NULL);
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), priv->views_stack);
|
|
||||||
|
|
||||||
gtk_style_context_add_class (
|
|
||||||
gtk_widget_get_style_context (priv->views_stack),
|
|
||||||
"views");
|
|
||||||
|
|
||||||
priv->views[GCAL_WINDOW_VIEW_WEEK] =
|
priv->views[GCAL_WINDOW_VIEW_WEEK] =
|
||||||
gcal_week_view_new (priv->manager);
|
gcal_week_view_new (priv->manager);
|
||||||
@@ -1154,16 +1091,6 @@ gcal_window_constructed (GObject *object)
|
|||||||
"active-date",
|
"active-date",
|
||||||
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (priv->views_switcher),
|
|
||||||
GTK_STACK (priv->views_stack));
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (object), priv->main_box);
|
|
||||||
gtk_widget_show_all (priv->main_box);
|
|
||||||
|
|
||||||
gtk_style_context_add_class (
|
|
||||||
gtk_widget_get_style_context (GTK_WIDGET (object)),
|
|
||||||
"views");
|
|
||||||
|
|
||||||
/* popover and content */
|
/* popover and content */
|
||||||
priv->popover = gtk_popover_new (GTK_WIDGET(priv->views_stack));
|
priv->popover = gtk_popover_new (GTK_WIDGET(priv->views_stack));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user