~noskcaj/ubuntu/vivid/gthumb/flickr-https

« back to all changes in this revision

Viewing changes to gthumb/gth-info-bar.c

  • Committer: Package Import Robot
  • Author(s): Jackson Doak
  • Date: 2014-04-08 06:31:09 UTC
  • mfrom: (1.3.20)
  • Revision ID: package-import@ubuntu.com-20140408063109-tk845map8ji6uxvd
Tags: 3:3.3.1.is.3.2.7-0ubuntu1
* Revert to newest upstream stable release. LP: #1290691
  - Refresh patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
 
44
44
static void
 
45
gth_info_bar_init (GthInfoBar *self)
 
46
{
 
47
        self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_INFO_BAR, GthInfoBarPrivate);
 
48
}
 
49
 
 
50
 
 
51
static void
45
52
infobar_response_cb (GtkInfoBar *self,
46
53
                     int         response_id,
47
54
                     gpointer    user_data)
55
62
 
56
63
 
57
64
static void
58
 
gth_info_bar_init (GthInfoBar *self)
 
65
gth_info_bar_construct (GthInfoBar *self)
59
66
{
60
67
        GtkWidget *hbox_content;
61
68
        GtkWidget *image;
63
70
        GtkWidget *primary_label;
64
71
        GtkWidget *secondary_label;
65
72
        GtkWidget *area;
66
 
 
67
 
        self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_INFO_BAR, GthInfoBarPrivate);
68
 
 
 
73
        
69
74
        hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
70
75
        gtk_widget_show (hbox_content);
71
76
 
86
91
        gtk_label_set_ellipsize (GTK_LABEL (primary_label), PANGO_ELLIPSIZE_MIDDLE);
87
92
        gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5);
88
93
        gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
89
 
 
 
94
        
90
95
        self->priv->secondary_text_label = secondary_label = gtk_label_new (NULL);
91
96
        gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
92
97
        gtk_widget_set_can_focus (secondary_label, TRUE);
96
101
        gtk_label_set_ellipsize (GTK_LABEL (secondary_label), PANGO_ELLIPSIZE_END);
97
102
        gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
98
103
        gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
99
 
 
 
104
        
100
105
        area = gtk_info_bar_get_action_area (GTK_INFO_BAR (self));
101
106
        gtk_container_set_border_width (GTK_CONTAINER (self), 0);
102
107
        gtk_box_set_homogeneous (GTK_BOX (area), FALSE);
108
113
 
109
114
        gtk_widget_set_name (GTK_WIDGET (self), "GthInfoBar");
110
115
        gtk_info_bar_set_message_type (GTK_INFO_BAR (self), GTK_MESSAGE_OTHER);
 
116
        gtk_container_set_border_width (GTK_CONTAINER (self), 0);
111
117
 
112
118
        g_signal_connect (self,
113
119
                          "response",
117
123
 
118
124
 
119
125
GtkWidget *
120
 
gth_info_bar_new (void)
 
126
gth_info_bar_new (const char *icon_stock_id,
 
127
                  const char *primary_text,
 
128
                  const char *secondary_text)
121
129
{
122
 
        return GTK_WIDGET (g_object_new (GTH_TYPE_INFO_BAR, NULL));
 
130
        GthInfoBar *self;
 
131
 
 
132
        self = g_object_new (GTH_TYPE_INFO_BAR, NULL);
 
133
        gth_info_bar_construct (self);
 
134
        gth_info_bar_set_icon (self, icon_stock_id);
 
135
        gth_info_bar_set_primary_text (self, primary_text);
 
136
        gth_info_bar_set_secondary_text (self, secondary_text);
 
137
        
 
138
        return (GtkWidget *) self;
123
139
}
124
140
 
125
141
 
131
147
 
132
148
 
133
149
void
134
 
gth_info_bar_set_icon_name (GthInfoBar  *self,
135
 
                            const char  *icon_name,
136
 
                            GtkIconSize  icon_size)
 
150
gth_info_bar_set_icon (GthInfoBar *self,
 
151
                       const char *icon_stock_id)
137
152
{
138
 
        if (icon_name == NULL) {
 
153
        if (icon_stock_id == NULL) {
139
154
                gtk_widget_hide (self->priv->icon_image);
140
155
                return;
141
156
        }
142
157
 
143
 
        gtk_image_set_from_icon_name (GTK_IMAGE (self->priv->icon_image), icon_name, icon_size);
 
158
        gtk_image_set_from_stock (GTK_IMAGE (self->priv->icon_image), icon_stock_id, GTK_ICON_SIZE_BUTTON);
144
159
        gtk_widget_show (self->priv->icon_image);
145
160
}
146
161
 
147
162
 
148
163
void
149
 
gth_info_bar_set_gicon (GthInfoBar  *self,
150
 
                        GIcon       *icon,
151
 
                        GtkIconSize  icon_size)
 
164
gth_info_bar_set_gicon (GthInfoBar *self,
 
165
                        GIcon      *icon)
152
166
{
153
167
        if (icon == NULL) {
154
168
                gtk_widget_hide (self->priv->icon_image);
155
169
                return;
156
170
        }
157
171
 
158
 
        gtk_image_set_from_gicon (GTK_IMAGE (self->priv->icon_image), icon, icon_size);
 
172
        gtk_image_set_from_gicon (GTK_IMAGE (self->priv->icon_image), icon, GTK_ICON_SIZE_BUTTON);
159
173
        gtk_widget_show (self->priv->icon_image);
160
174
}
161
175
 
171
185
                gtk_widget_hide (self->priv->primary_text_label);
172
186
                return;
173
187
        }
174
 
 
 
188
        
175
189
        escaped = g_markup_escape_text (text, -1);
176
190
        markup = g_strdup_printf ("<b>%s</b>", escaped);
177
191
        gtk_label_set_markup (GTK_LABEL (self->priv->primary_text_label), markup);
178
192
        gtk_widget_show (self->priv->primary_text_label);
179
 
 
 
193
        
180
194
        g_free (markup);
181
195
        g_free (escaped);
182
196
}
193
207
                gtk_widget_hide (self->priv->secondary_text_label);
194
208
                return;
195
209
        }
196
 
 
 
210
        
197
211
        escaped = g_markup_escape_text (text, -1);
198
212
        markup = g_strdup_printf ("<small>%s</small>", escaped);
199
213
        gtk_label_set_markup (GTK_LABEL (self->priv->secondary_text_label), markup);
200
214
        gtk_widget_show (self->priv->secondary_text_label);
201
 
 
 
215
        
202
216
        g_free (markup);
203
217
        g_free (escaped);
204
218
}