~noskcaj/ubuntu/trusty/gnome-documents/3.10.2

« back to all changes in this revision

Viewing changes to libgd/libgd/gd-stack-switcher.c

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson, Jeremy Bicha
  • Date: 2013-06-17 22:24:54 UTC
  • mfrom: (3.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20130617222454-biw3dmaqdd9qpbh7
Tags: 3.8.3.1-1
[ Jeremy Bicha ]
* New upstream release
* debian/control.in:
  - Add missing dependency on gir1.2-gnomedesktop-3.0
  - Bump minimum GTK for newer libgd
  - Build-depend on gtk-doc-tools and yelp-tools
  - Build-depend on inkscape and poppler-utils to generate
    getting-started PDF
* debian/rules: --enable-getting-started

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "gd-stack-switcher.h"
 
21
#include "gd-header-button.h"
21
22
 
22
23
struct _GdStackSwitcherPrivate
23
24
{
77
78
{
78
79
  char *title;
79
80
  char *symbolic_icon_name;
80
 
  GtkStyleContext *context;
81
 
  GtkWidget *button_child;
82
81
 
83
82
  gtk_container_child_get (GTK_CONTAINER (self->priv->stack), widget,
84
83
                           "title", &title,
85
84
                           "symbolic-icon-name", &symbolic_icon_name,
86
85
                           NULL);
87
86
 
88
 
  context = gtk_widget_get_style_context (button);
89
 
  button_child = gtk_bin_get_child (GTK_BIN (button));
90
 
 
91
 
  if (symbolic_icon_name != NULL && symbolic_icon_name[0] != '\0')
92
 
    {
93
 
      if (button_child != NULL && !GTK_IS_IMAGE (button_child))
94
 
        {
95
 
          gtk_widget_set_size_request (button, -1, -1);
96
 
          gtk_widget_destroy (button_child);
97
 
          button_child = NULL;
98
 
        }
99
 
 
100
 
      if (button_child == NULL)
101
 
        {
102
 
          button_child = gtk_image_new ();
103
 
          gtk_container_add (GTK_CONTAINER (button), button_child);
104
 
          gtk_widget_show (button_child);
105
 
        }
106
 
 
107
 
      gtk_image_set_from_icon_name (GTK_IMAGE (button_child), symbolic_icon_name, GTK_ICON_SIZE_MENU);
108
 
      gtk_widget_set_tooltip_text (button, title);
109
 
 
110
 
      gtk_style_context_add_class (context, "image-button");
111
 
      gtk_style_context_remove_class (context, "text-button");
112
 
    }
 
87
  gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (button), symbolic_icon_name);
 
88
  gd_header_button_set_label (GD_HEADER_BUTTON (button), title);
 
89
 
 
90
  gtk_widget_set_visible (button, title != NULL || symbolic_icon_name != NULL);
 
91
 
 
92
  if (symbolic_icon_name != NULL)
 
93
    gtk_widget_set_size_request (button, -1, -1);
113
94
  else
114
 
    {
115
 
      if (button_child != NULL && GTK_IS_LABEL (button_child))
116
 
        gtk_label_set_text (GTK_LABEL (button_child), title);
117
 
      else
118
 
        {
119
 
          if (button_child)
120
 
            gtk_widget_destroy (button_child);
121
 
          button_child = gtk_label_new (title);
122
 
          gtk_widget_show (button_child);
123
 
          gtk_container_add (GTK_CONTAINER (button), button_child);
124
 
          gtk_widget_set_size_request (button, 100, -1);
125
 
 
126
 
          gtk_style_context_add_class (context, "text-button");
127
 
          gtk_style_context_remove_class (context, "image-button");
128
 
        }
129
 
    }
 
95
    gtk_widget_set_size_request (button, 100, -1);
130
96
 
131
97
  g_free (title);
132
98
  g_free (symbolic_icon_name);
169
135
  GList *group;
170
136
  GtkStyleContext *context;
171
137
 
172
 
  button = gtk_radio_button_new (NULL);
173
 
  context = gtk_widget_get_style_context (button);
174
 
  gtk_style_context_add_class (context, "raised");
175
 
 
 
138
  button = gd_header_radio_button_new ();
176
139
  update_button (self, widget, button);
177
140
 
178
 
  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
179
 
 
180
141
  group = gtk_container_get_children (GTK_CONTAINER (self));
181
142
  if (group != NULL)
182
143
    {
185
146
    }
186
147
 
187
148
  gtk_container_add (GTK_CONTAINER (self), button);
188
 
  gtk_widget_show (button);
189
149
 
190
150
  g_object_set_data (G_OBJECT (button), "stack-child", widget);
191
151
  g_signal_connect (button, "clicked", G_CALLBACK (on_button_clicked), self);
257
217
  g_signal_handlers_disconnect_by_func (priv->stack, on_stack_child_removed, switcher);
258
218
 
259
219
  g_signal_handlers_disconnect_by_func (priv->stack, on_child_changed, switcher);
 
220
 
 
221
  g_signal_handlers_disconnect_by_func (priv->stack, disconnect_stack_signals, switcher);
260
222
}
261
223
 
262
224
static void
270
232
                          G_CALLBACK (on_stack_child_removed), switcher);
271
233
  g_signal_connect (priv->stack, "notify::visible-child",
272
234
                    G_CALLBACK (on_child_changed), switcher);
 
235
 
 
236
  g_signal_connect_swapped (priv->stack, "destroy",
 
237
                            G_CALLBACK (disconnect_stack_signals), switcher);
273
238
}
274
239
 
275
240
/**