[gedit] Use a template for the progress info bar
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Use a template for the progress info bar
- Date: Sun, 28 Apr 2013 16:04:49 +0000 (UTC)
commit 277cd3b842f5d2ebbb9aedb814e3f4968195e4ea
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Apr 28 18:04:16 2013 +0200
Use a template for the progress info bar
gedit/Makefile.am | 3 +-
gedit/gedit-progress-info-bar.c | 59 ++++++--------------------
gedit/gedit-progress-info-bar.ui | 88 ++++++++++++++++++++++++++++++++++++++
gedit/gedit.gresource.xml | 1 +
4 files changed, 104 insertions(+), 47 deletions(-)
---
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index 16f1d57..27b1f01 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -263,7 +263,8 @@ EXTRA_DIST = \
gedit-preferences-dialog.ui \
gedit-replace-dialog.ui \
gedit-print-preview.ui \
- gedit-print-preferences.ui
+ gedit-print-preferences.ui \
+ gedit-progress-info-bar.ui
CLEANFILES = $(BUILT_SOURCES) $(BUILT_SOURCES_PRIVATE)
diff --git a/gedit/gedit-progress-info-bar.c b/gedit/gedit-progress-info-bar.c
index 9291d98..b9f1b46 100644
--- a/gedit/gedit-progress-info-bar.c
+++ b/gedit/gedit-progress-info-bar.c
@@ -20,16 +20,6 @@
* Boston, MA 02111-1307, USA.
*/
-/*
- * Modified by the gedit Team, 2005. See the AUTHORS file for a
- * list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- *
- * $Id$
- */
-
- /* TODO: add properties */
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -65,8 +55,6 @@ gedit_progress_info_bar_set_has_cancel_button (GeditProgressInfoBar *bar,
gtk_info_bar_add_button (GTK_INFO_BAR (bar),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
-
- g_object_notify (G_OBJECT (bar), "has-cancel-button");
}
static void
@@ -95,6 +83,7 @@ static void
gedit_progress_info_bar_class_init (GeditProgressInfoBarClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gobject_class->set_property = gedit_progress_info_bar_set_property;
@@ -108,46 +97,24 @@ gedit_progress_info_bar_class_init (GeditProgressInfoBarClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+ /* Bind class to template */
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/gedit/ui/gedit-progress-info-bar.ui");
+ gtk_widget_class_bind_child (widget_class, GeditProgressInfoBarPrivate, image);
+ gtk_widget_class_bind_child (widget_class, GeditProgressInfoBarPrivate, label);
+ gtk_widget_class_bind_child (widget_class, GeditProgressInfoBarPrivate, progress);
+
g_type_class_add_private (gobject_class, sizeof (GeditProgressInfoBarPrivate));
}
static void
gedit_progress_info_bar_init (GeditProgressInfoBar *bar)
{
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *content;
-
- bar->priv = GEDIT_PROGRESS_INFO_BAR_GET_PRIVATE (bar);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_widget_show (vbox);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
-
- bar->priv->image = gtk_image_new_from_icon_name (GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- gtk_widget_show (bar->priv->image);
- gtk_box_pack_start (GTK_BOX (hbox), bar->priv->image, FALSE, FALSE, 4);
-
- bar->priv->label = gtk_label_new ("");
- gtk_widget_show (bar->priv->label);
- gtk_box_pack_start (GTK_BOX (hbox), bar->priv->label, FALSE, TRUE, 0);
- gtk_label_set_use_markup (GTK_LABEL (bar->priv->label), TRUE);
- gtk_widget_set_halign (bar->priv->label, GTK_ALIGN_START);
- gtk_label_set_ellipsize (GTK_LABEL (bar->priv->label),
- PANGO_ELLIPSIZE_END);
-
- bar->priv->progress = gtk_progress_bar_new ();
- gtk_widget_set_hexpand (bar->priv->progress, TRUE);
- gtk_widget_show (bar->priv->progress);
- gtk_box_pack_start (GTK_BOX (vbox), bar->priv->progress, FALSE, TRUE, 0);
- gtk_widget_set_size_request (bar->priv->progress, -1, 15);
-
- content = gtk_info_bar_get_content_area (GTK_INFO_BAR (bar));
- gtk_container_add (GTK_CONTAINER (content), vbox);
+ bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (bar,
+ GEDIT_TYPE_PROGRESS_INFO_BAR,
+ GeditProgressInfoBarPrivate);
+
+ gtk_widget_init_template (GTK_WIDGET (bar));
}
GtkWidget *
diff --git a/gedit/gedit-progress-info-bar.ui b/gedit/gedit-progress-info-bar.ui
new file mode 100644
index 0000000..2479e13
--- /dev/null
+++ b/gedit/gedit-progress-info-bar.ui
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.6 -->
+ <template class="GeditProgressInfoBar" parent="GtkInfoBar">
+ <property name="visible">True</property>
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="content_area">
+ <object class="GtkBox" id="infobar-content_area1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
+ <property name="icon-size">2</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">4</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label">label</property>
+ <property name="use_markup">True</property>
+ <property name="ellipsize">end</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="progress">
+ <property name="height_request">15</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="infobar-action_area1">
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/gedit/gedit.gresource.xml b/gedit/gedit.gresource.xml
index 3035ff2..d3fee40 100644
--- a/gedit/gedit.gresource.xml
+++ b/gedit/gedit.gresource.xml
@@ -9,5 +9,6 @@
<file preprocess="xml-stripblanks">gedit-replace-dialog.ui</file>
<file preprocess="xml-stripblanks">gedit-print-preview.ui</file>
<file preprocess="xml-stripblanks">gedit-print-preferences.ui</file>
+ <file preprocess="xml-stripblanks">gedit-progress-info-bar.ui</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]