Пример #1
0
static void
bjb_empty_results_box_constructed (GObject *object)
{
  BjbEmptyResultsBox *self;
  BjbEmptyResultsBoxPrivate *priv;
  GtkStyleContext *context;
  GdkPixbuf *pixbuf;
  GtkWidget *labels_grid;
  gchar *label, *icons_path, *note_icon_path, *markup;
  GError *error;

  G_OBJECT_CLASS (bjb_empty_results_box_parent_class)->constructed (object);
  self = BJB_EMPTY_RESULTS_BOX (object);
  priv = self->priv;

  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_HORIZONTAL);
  gtk_grid_set_column_spacing (GTK_GRID (self), 12);

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  gtk_style_context_add_class (context, "dim-label");

  icons_path = (gchar*) bijiben_get_bijiben_dir ();
  note_icon_path = g_build_filename (icons_path,
                                "bijiben",
                                "icons",
                                "hicolor",
                                "scalable",
                                "actions",
                                "note.svg",
                                NULL);

  error = NULL;
  pixbuf = gdk_pixbuf_new_from_file (note_icon_path, &error);

  if (error)
  {
    g_warning ("%s", error->message);
    g_error_free (error);
  }

  priv->image  = gtk_image_new_from_pixbuf (pixbuf);
  g_free (note_icon_path);

  gtk_image_set_pixel_size (GTK_IMAGE (priv->image), 64);
  gtk_container_add (GTK_CONTAINER (self), priv->image);

  labels_grid = gtk_grid_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (labels_grid), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_row_spacing (GTK_GRID (labels_grid), 12);
  gtk_container_add (GTK_CONTAINER (self), labels_grid);

  label = _("No Notes Found");
  markup = g_markup_printf_escaped ("<big><b>%s</b></big>", label);

  priv->primary_label = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (priv->primary_label), markup);
  g_free (markup);

  gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START);
  gtk_widget_set_vexpand (priv->primary_label, TRUE);
  gtk_label_set_use_markup (GTK_LABEL (priv->primary_label), TRUE);
  gtk_container_add (GTK_CONTAINER (labels_grid), priv->primary_label);


  self->priv->type = BJB_EMPTY_RESULTS_TYPE;
  label = "";
  self->priv->details_label = GTK_LABEL (gtk_label_new (label));
  gtk_label_set_use_markup (GTK_LABEL (self->priv->details_label), TRUE);
  gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START);
  // xalign: 0,
  // max_width_chars: 24,
  // wrap: true

  gtk_container_add (GTK_CONTAINER (labels_grid), GTK_WIDGET (self->priv->details_label));

  gtk_widget_set_valign (priv->primary_label, GTK_ALIGN_CENTER);
  gtk_widget_show_all (GTK_WIDGET (self));
}
Пример #2
0
void
bjb_window_base_switch_to (BjbWindowBase *self, BjbWindowViewType type)
{
  BjbWindowBasePriv *priv = self->priv;
  priv->current_view = type;

  if (type != BJB_WINDOW_BASE_NOTE_VIEW)
    destroy_note_if_needed (self);

  switch (type)
  {

    /* Precise the window does not display any specific note
     * Refresh the model
     * Ensure the main view receives the proper signals
     *
     * main view & archive view are the same widget
     */

    case BJB_WINDOW_BASE_MAIN_VIEW:
      bjb_search_toolbar_connect (priv->search_bar);
      bjb_main_view_connect_signals (priv->view);
      gtk_widget_show (GTK_WIDGET (priv->search_bar));
      gtk_stack_set_visible_child_name (priv->stack, "main-view");
      break;

   case BJB_WINDOW_BASE_ARCHIVE_VIEW:
      bjb_search_toolbar_connect (priv->search_bar);
      bjb_main_view_connect_signals (priv->view);
      gtk_widget_show (GTK_WIDGET (priv->search_bar));
      gtk_stack_set_visible_child_name (priv->stack, "main-view");
      break;

    case BJB_WINDOW_BASE_SPINNER_VIEW:
      gtk_stack_set_visible_child_name (priv->stack, "spinner");
      break;


    case BJB_WINDOW_BASE_NO_NOTE:
      bjb_empty_results_box_set_type (BJB_EMPTY_RESULTS_BOX (priv->no_note),
                                      BJB_EMPTY_RESULTS_NO_NOTE);
      gtk_widget_show (priv->no_note);
      gtk_widget_hide (GTK_WIDGET (priv->search_bar));
      gtk_stack_set_visible_child_name (priv->stack, "empty");
      break;


    case BJB_WINDOW_BASE_NO_RESULT:
      bjb_empty_results_box_set_type (BJB_EMPTY_RESULTS_BOX (priv->no_note),
                                      BJB_EMPTY_RESULTS_NO_RESULTS);
      gtk_widget_show (priv->no_note);
      gtk_stack_set_visible_child_name (priv->stack, "empty");
      break;


    case BJB_WINDOW_BASE_ERROR_TRACKER:
      bjb_empty_results_box_set_type (BJB_EMPTY_RESULTS_BOX (priv->no_note),
                                      BJB_EMPTY_RESULTS_TRACKER);
      gtk_widget_show_all (priv->no_note);
      gtk_widget_hide (GTK_WIDGET (priv->search_bar));
      gtk_stack_set_visible_child_name (priv->stack, "empty");
      break;


    case BJB_WINDOW_BASE_NOTE_VIEW:
      gtk_widget_show_all (GTK_WIDGET (priv->note_view));
      gtk_widget_hide (GTK_WIDGET (priv->search_bar));
      gtk_stack_set_visible_child_name (priv->stack, "note-view");
      break;


    default:
      return;
  }

  g_signal_emit (G_OBJECT (self), bjb_win_base_signals[BJB_WIN_BASE_VIEW_CHANGED],0);
}
Пример #3
0
static void
bjb_empty_results_box_constructed (GObject *object)
{
  BjbEmptyResultsBox *self;
  BjbEmptyResultsBoxPrivate *priv;
  GtkStyleContext *context;
  GtkWidget *labels_grid;
  gchar *label, *markup;
  GFile *note_icon_file;
  GIcon *icon;

  G_OBJECT_CLASS (bjb_empty_results_box_parent_class)->constructed (object);
  self = BJB_EMPTY_RESULTS_BOX (object);
  priv = self->priv;

  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_HORIZONTAL);
  gtk_grid_set_column_spacing (GTK_GRID (self), 12);

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  gtk_style_context_add_class (context, "dim-label");

  note_icon_file = g_file_new_for_uri ("resource://org/gnome/bijiben/note-symbolic.svg");
  icon = g_file_icon_new (note_icon_file);
  g_object_unref (note_icon_file);

  priv->image  = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  g_object_unref (icon);

  gtk_container_add (GTK_CONTAINER (self), priv->image);

  labels_grid = gtk_grid_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (labels_grid), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_row_spacing (GTK_GRID (labels_grid), 0);
  gtk_widget_set_valign (labels_grid, GTK_ALIGN_START);
  gtk_container_add (GTK_CONTAINER (self), labels_grid);

  label = _("No notes");
  markup = g_markup_printf_escaped ("<big><b>%s</b></big>", label);

  priv->primary_label = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (priv->primary_label), markup);
  g_free (markup);

  gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START);
  gtk_widget_set_vexpand (priv->primary_label, TRUE);
  gtk_label_set_use_markup (GTK_LABEL (priv->primary_label), TRUE);
  gtk_container_add (GTK_CONTAINER (labels_grid), priv->primary_label);


  self->priv->type = BJB_EMPTY_RESULTS_TYPE;
  label = "";
  self->priv->details_label = GTK_LABEL (gtk_label_new (label));
  gtk_label_set_use_markup (GTK_LABEL (self->priv->details_label), TRUE);
  gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START);
  // xalign: 0,
  // max_width_chars: 24,
  // wrap: true

  gtk_container_add (GTK_CONTAINER (labels_grid), GTK_WIDGET (self->priv->details_label));

  gtk_widget_set_valign (priv->primary_label, GTK_ALIGN_CENTER);
  gtk_widget_show_all (GTK_WIDGET (self));
}