Add the house system configuration widgets to the Edit tab

It is already filled with data, but it is not functional yet!
This commit is contained in:
Gergely Polonkai 2014-07-17 00:18:18 +02:00
parent 1ae2db0232
commit 09d1fe352a
2 changed files with 79 additions and 2 deletions

View File

@ -29,6 +29,7 @@ struct _AgWindowPrivate {
GtkWidget *minute; GtkWidget *minute;
GtkWidget *second; GtkWidget *second;
GtkWidget *timezone; GtkWidget *timezone;
GtkWidget *house_system;
GtkWidget *tab_chart; GtkWidget *tab_chart;
GtkWidget *tab_edit; GtkWidget *tab_edit;
@ -43,6 +44,7 @@ struct _AgWindowPrivate {
gchar *uri; gchar *uri;
gboolean aspect_table_populated; gboolean aspect_table_populated;
GtkTextBuffer *note_buffer; GtkTextBuffer *note_buffer;
GtkListStore *house_system_model;
}; };
G_DEFINE_QUARK(ag_window_error_quark, ag_window_error); G_DEFINE_QUARK(ag_window_error_quark, ag_window_error);
@ -871,11 +873,28 @@ ag_window_display_changed(GSettings *settings, gchar *key, AgWindow *window)
ag_window_redraw_aspect_table(window); ag_window_redraw_aspect_table(window);
} }
static void
ag_window_add_house_system(GsweHouseSystemInfo *house_system_info,
AgWindowPrivate *priv)
{
GtkTreeIter iter;
gtk_list_store_append(priv->house_system_model, &iter);
gtk_list_store_set(
priv->house_system_model, &iter,
0, gswe_house_system_info_get_house_system(house_system_info),
1, gswe_house_system_info_get_name(house_system_info),
-1
);
}
static void static void
ag_window_init(AgWindow *window) ag_window_init(AgWindow *window)
{ {
GtkAccelGroup *accel_group; GtkAccelGroup *accel_group;
GSettings *main_settings; GSettings *main_settings;
GList *house_system_list;
GtkCellRenderer *house_system_renderer;
AgWindowPrivate *priv = ag_window_get_instance_private(window); AgWindowPrivate *priv = ag_window_get_instance_private(window);
gtk_widget_init_template(GTK_WIDGET(window)); gtk_widget_init_template(GTK_WIDGET(window));
@ -896,6 +915,23 @@ ag_window_init(AgWindow *window)
window window
); );
house_system_list = gswe_all_house_systems();
g_list_foreach(house_system_list, (GFunc)ag_window_add_house_system, priv);
g_list_free(house_system_list);
house_system_renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(
GTK_CELL_LAYOUT(priv->house_system),
house_system_renderer,
TRUE
);
gtk_cell_layout_set_attributes(
GTK_CELL_LAYOUT(priv->house_system),
house_system_renderer,
"text", 1,
NULL
);
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack), "edit"); gtk_stack_set_visible_child_name(GTK_STACK(priv->stack), "edit");
priv->current_tab = priv->tab_edit; priv->current_tab = priv->tab_edit;
g_object_set( g_object_set(
@ -996,6 +1032,16 @@ ag_window_class_init(AgWindowClass *klass)
AgWindow, AgWindow,
longitude longitude
); );
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
house_system_model
);
gtk_widget_class_bind_template_child_private(
widget_class,
AgWindow,
house_system
);
gtk_widget_class_bind_template_child_private( gtk_widget_class_bind_template_child_private(
widget_class, widget_class,
AgWindow, AgWindow,

View File

@ -104,6 +104,14 @@
<property name="step_increment">1</property> <property name="step_increment">1</property>
<property name="page_increment">10</property> <property name="page_increment">10</property>
</object> </object>
<object class="GtkListStore" id="house_system_model">
<columns>
<!-- column-name house-system-id -->
<column type="GsweHouseSystem"/>
<!-- column-name house-system-name -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkTextBuffer" id="note_buffer"> <object class="GtkTextBuffer" id="note_buffer">
</object> </object>
<template class="AgWindow" parent="GtkApplicationWindow"> <template class="AgWindow" parent="GtkApplicationWindow">
@ -510,8 +518,8 @@
<property name="label" translatable="yes" context="Chart edit, Timezone label">Timezone</property> <property name="label" translatable="yes" context="Chart edit, Timezone label">Timezone</property>
</object> </object>
<packing> <packing>
<property name="left_attach">4</property> <property name="left_attach">7</property>
<property name="top_attach">5</property> <property name="top_attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -521,6 +529,29 @@
<property name="adjustment">timezone_adjust</property> <property name="adjustment">timezone_adjust</property>
<property name="digits">1</property> <property name="digits">1</property>
</object> </object>
<packing>
<property name="left_attach">7</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="house_system_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="Chart edit, House system label">House system</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="house_system">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">house_system_model</property>
<property name="id_column">0</property>
</object>
<packing> <packing>
<property name="left_attach">5</property> <property name="left_attach">5</property>
<property name="top_attach">5</property> <property name="top_attach">5</property>