示例#1
0
static void
photos_error_box_constructed (GObject *object)
{
  PhotosErrorBox *self = PHOTOS_ERROR_BOX (object);

  G_OBJECT_CLASS (photos_error_box_parent_class)->constructed (object);

  gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
  gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
  gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
  gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_row_spacing (GTK_GRID (self), 12);

  self->image = gtk_image_new_from_icon_name ("dialog-error", GTK_ICON_SIZE_INVALID);
  gtk_image_set_pixel_size (GTK_IMAGE (self->image), 128);
  gtk_widget_set_halign (self->image, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (self->image, GTK_ALIGN_CENTER);
  gtk_container_add (GTK_CONTAINER (self), self->image);

  self->primary_label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (self->primary_label), TRUE);
  gtk_widget_set_halign (self->primary_label, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (self->primary_label, GTK_ALIGN_CENTER);
  gtk_container_add (GTK_CONTAINER (self), self->primary_label);

  self->secondary_label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (self->secondary_label), TRUE);
  gtk_label_set_line_wrap (GTK_LABEL (self->secondary_label), TRUE);
  gtk_widget_set_halign (self->secondary_label, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (self->secondary_label, GTK_ALIGN_CENTER);
  gtk_container_add (GTK_CONTAINER (self), self->secondary_label);

  gtk_widget_show_all (GTK_WIDGET (self));
}
static void
photos_view_container_set_error (PhotosViewContainer *self, const gchar *primary, const gchar *secondary)
{
  PhotosViewContainerPrivate *priv = self->priv;

  photos_error_box_update (PHOTOS_ERROR_BOX (priv->error_box), primary, secondary);
  gtk_stack_set_visible_child_name (GTK_STACK (self), "error");
}