source-dialog: use a builder .ui definition for interface
We know that coding interfaces sucks, so use a .ui file instead.
This commit is contained in:
committed by
Erick Pérez Castellanos
parent
b1fc6991e9
commit
ef9d1301d9
@@ -49,6 +49,7 @@ EXTRA_DIST= \
|
||||
org.gnome.Calendar.desktop \
|
||||
calendar.gresource.xml \
|
||||
shell-search-provider-dbus-interfaces.xml \
|
||||
ui/calendar-row.ui \
|
||||
ui/date-selector.ui \
|
||||
ui/edit-dialog.ui \
|
||||
ui/menus.ui \
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/gnome/calendar">
|
||||
<file alias="calendar-row.ui" compressed="true" preprocess="xml-stripblanks">ui/calendar-row.ui</file>
|
||||
<file alias="date-selector.ui" compressed="true" preprocess="xml-stripblanks">ui/date-selector.ui</file>
|
||||
<file alias="edit-dialog.ui" compressed="true" preprocess="xml-stripblanks">ui/edit-dialog.ui</file>
|
||||
<file alias="menus.ui" compressed="true" preprocess="xml-stripblanks">ui/menus.ui</file>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.16"/>
|
||||
<object class="GtkListBoxRow" id="row">
|
||||
<property name="width_request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">6</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="icon">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="pixel_size">24</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="height">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="subtitle">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="title">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
+17
-17
@@ -597,6 +597,7 @@ make_row_from_source (GcalSourceDialog *dialog,
|
||||
ESource *source)
|
||||
{
|
||||
GcalSourceDialogPrivate *priv;
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *bottom_label;
|
||||
GtkWidget *top_label;
|
||||
GdkPixbuf *pixbuf;
|
||||
@@ -608,37 +609,36 @@ make_row_from_source (GcalSourceDialog *dialog,
|
||||
|
||||
priv = dialog->priv;
|
||||
get_source_parent_name_color (priv->manager, source, &parent_name, NULL);
|
||||
row = gtk_list_box_row_new ();
|
||||
builder = gtk_builder_new_from_resource ("/org/gnome/calendar/calendar-row.ui");
|
||||
|
||||
/*
|
||||
* Since we're destroying the builder instance before adding
|
||||
* the row to the listbox, it should be referenced here so
|
||||
* it isn't destroyed with the GtkBuilder.
|
||||
*/
|
||||
row = g_object_ref (gtk_builder_get_object (builder, "row"));
|
||||
|
||||
/* main box */
|
||||
grid = g_object_new (GTK_TYPE_GRID, "border-width", 6, "column-spacing", 12, NULL);
|
||||
grid = GTK_WIDGET (gtk_builder_get_object (builder, "grid"));
|
||||
|
||||
/* source color icon */
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (source));
|
||||
pixbuf = get_circle_pixbuf_from_color (&color, 24);
|
||||
icon = gtk_image_new_from_pixbuf (pixbuf);
|
||||
icon = GTK_WIDGET (gtk_builder_get_object (builder, "icon"));
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (icon), pixbuf);
|
||||
|
||||
/* source name label */
|
||||
top_label = g_object_new (GTK_TYPE_LABEL,
|
||||
"label", e_source_get_display_name (source),
|
||||
"xalign", 0.0,
|
||||
"hexpand", TRUE,
|
||||
NULL);
|
||||
top_label = GTK_WIDGET (gtk_builder_get_object (builder, "title"));
|
||||
gtk_label_set_label (GTK_LABEL (top_label), e_source_get_display_name (source));
|
||||
g_object_bind_property (source, "display-name", top_label, "label", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_signal_connect (source, "notify::display-name", G_CALLBACK (invalidate_calendar_listbox_sort),
|
||||
priv->calendars_listbox);
|
||||
|
||||
/* parent source name label */
|
||||
bottom_label = g_object_new (GTK_TYPE_LABEL, "label", parent_name, "xalign", 0.0, "hexpand", TRUE, NULL);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (bottom_label), "dim-label");
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), icon, 0, 0, 1, 2);
|
||||
gtk_grid_attach (GTK_GRID (grid), top_label, 1, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), bottom_label, 1, 1, 1, 1);
|
||||
gtk_container_add (GTK_CONTAINER (row), grid);
|
||||
|
||||
gtk_widget_show_all (row);
|
||||
bottom_label = GTK_WIDGET (gtk_builder_get_object (builder, "subtitle"));
|
||||
gtk_label_set_label (GTK_LABEL (bottom_label), parent_name);
|
||||
|
||||
g_object_unref (builder);
|
||||
g_object_unref (pixbuf);
|
||||
g_free (parent_name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user