static void
photos_organize_collection_view_init (PhotosOrganizeCollectionView *self)
{
  GApplication *app;
  PhotosSearchContextState *state;

  app = g_application_get_default ();
  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));

  self->cancellable = g_cancellable_new ();

  self->model = photos_organize_collection_model_new ();
  gtk_tree_view_set_model (GTK_TREE_VIEW (self), GTK_TREE_MODEL (self->model));

  self->view_col = gtk_tree_view_column_new ();
  gtk_tree_view_append_column (GTK_TREE_VIEW (self), self->view_col);

  self->renderer_check = gtk_cell_renderer_toggle_new ();
  gtk_tree_view_column_pack_start (self->view_col, self->renderer_check, FALSE);
  gtk_tree_view_column_set_cell_data_func (self->view_col,
                                           self->renderer_check,
                                           photos_organize_collection_view_check_cell,
                                           self,
                                           NULL);
  g_signal_connect_swapped (self->renderer_check,
                            "toggled",
                            G_CALLBACK (photos_organize_collection_view_check_toggled),
                            self);

  self->renderer_text = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (self->view_col, self->renderer_text, TRUE);
  gtk_tree_view_column_add_attribute (self->view_col, self->renderer_text, "text", PHOTOS_ORGANIZE_MODEL_NAME);
  g_signal_connect_swapped (self->renderer_text,
                            "edited",
                            G_CALLBACK (photos_organize_collection_view_text_edited),
                            self);
  g_signal_connect_swapped (self->renderer_text,
                            "editing-canceled",
                            G_CALLBACK (photos_organize_collection_view_text_editing_canceled),
                            self);

  self->renderer_detail = gd_styled_text_renderer_new ();
  gtk_cell_renderer_set_padding (self->renderer_detail, 16, 0);
  gd_styled_text_renderer_add_class (GD_STYLED_TEXT_RENDERER (self->renderer_detail), "dim-label");
  gtk_tree_view_column_pack_start (self->view_col, self->renderer_detail, FALSE);
  gtk_tree_view_column_set_cell_data_func (self->view_col,
                                           self->renderer_detail,
                                           photos_organize_collection_view_detail_cell,
                                           self,
                                           NULL);

  self->item_mngr = g_object_ref (state->item_mngr);
  self->src_mngr = g_object_ref (state->src_mngr);
  self->sel_cntrlr = photos_selection_controller_dup_singleton ();

  gtk_widget_show (GTK_WIDGET (self));
}
Beispiel #2
0
static void
gb_book_links_construct (GbBookLinks *self)
{
    GbBookLinksPrivate *priv;
    GtkWidget *swindow;
    GtkTreeViewColumn *column;
    GtkCellRenderer *renderer;
    GtkTreeSelection *selection;

    priv = self->priv;

    swindow = gtk_scrolled_window_new (NULL, NULL);

    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow),
                                         GTK_SHADOW_IN);

    /* Create tree view */
    priv->tree_view = gtk_tree_view_new ();
    gtk_tree_view_set_activate_on_single_click (GTK_TREE_VIEW (priv->tree_view), TRUE);
    g_signal_connect_swapped (priv->tree_view, "row-activated",
                              G_CALLBACK (schedule_emit_link_activated), self);

    gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (priv->tree_view), FALSE);
    gtk_tree_view_set_level_indentation (GTK_TREE_VIEW (priv->tree_view), 20);

    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
    gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);

    gtk_container_add (GTK_CONTAINER (swindow), priv->tree_view);

    gtk_box_pack_start (GTK_BOX (self), swindow, TRUE, TRUE, 0);
    gtk_widget_show_all (GTK_WIDGET (self));

    column = gtk_tree_view_column_new ();
    gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
    gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), column);

    renderer = (GtkCellRenderer *)
            g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
                          "ellipsize", PANGO_ELLIPSIZE_END,
                          "weight", PANGO_WEIGHT_BOLD,
                          "xpad", 10,
                          NULL);
    gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), renderer, TRUE);
    
    gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), renderer,
                                         "markup", BOOK_LINKS_COLUMN_MARKUP,
                                         NULL);
    
    renderer = gd_styled_text_renderer_new ();
    gd_styled_text_renderer_add_class (GD_STYLED_TEXT_RENDERER (renderer), "dim-label");
    g_object_set (renderer,
                  "max-width-chars", 12,
                  "scale", PANGO_SCALE_SMALL,
                  "xalign", 1.0,
                  "xpad", 10,
                  NULL);
    gtk_tree_view_column_pack_end (GTK_TREE_VIEW_COLUMN (column), renderer, FALSE);
    /*
    gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), renderer,
                                         "text", BOOK_LINKS_COLUMN_LABEL,
                                         NULL);
    */
    priv->model = (GtkTreeModel *)gtk_list_store_new (BOOK_LINKS_COLUMN_N,
                                                      G_TYPE_STRING,
                                                      G_TYPE_STRING);
}