Ejemplo n.º 1
0
void
gimp_component_editor_set_view_size (GimpComponentEditor *editor,
                                     gint                 view_size)
{
  GtkWidget   *tree_widget;
  GtkStyle    *tree_style;
  GtkIconSize  icon_size;
  GtkTreeIter  iter;
  gboolean     iter_valid;

  g_return_if_fail (GIMP_IS_COMPONENT_EDITOR (editor));
  g_return_if_fail (view_size >  0 &&
                    view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE);

  tree_widget = GTK_WIDGET (editor->view);
  tree_style  = gtk_widget_get_style (tree_widget);

  icon_size = gimp_get_icon_size (tree_widget,
                                  GIMP_STOCK_VISIBLE,
                                  GTK_ICON_SIZE_BUTTON,
                                  view_size -
                                  2 * tree_style->xthickness,
                                  view_size -
                                  2 * tree_style->ythickness);

  g_object_set (editor->eye_cell,
                "stock-size", icon_size,
                NULL);

  for (iter_valid = gtk_tree_model_get_iter_first (editor->model, &iter);
       iter_valid;
       iter_valid = gtk_tree_model_iter_next (editor->model, &iter))
    {
      GimpViewRenderer *renderer;

      gtk_tree_model_get (editor->model, &iter,
                          COLUMN_RENDERER, &renderer,
                          -1);

      gimp_view_renderer_set_size (renderer, view_size, 1);
      g_object_unref (renderer);
    }

  editor->view_size = view_size;

  gtk_tree_view_columns_autosize (editor->view);
}
Ejemplo n.º 2
0
GtkWidget *
gimp_tool_view_new (GimpViewType     view_type,
                    GimpContainer   *container,
                    GimpContext     *context,
                    gint             view_size,
                    gint             view_border_width,
                    GimpMenuFactory *menu_factory)
{
  GimpToolView        *tool_view;
  GimpContainerEditor *editor;

  tool_view = g_object_new (GIMP_TYPE_TOOL_VIEW, NULL);

  if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (tool_view),
                                         view_type,
                                         container, context,
                                         view_size, view_border_width,
                                         menu_factory, "<Tools>",
                                         "/tools-popup"))
    {
      g_object_unref (tool_view);
      return NULL;
    }

  editor = GIMP_CONTAINER_EDITOR (tool_view);

  tool_view->raise_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
                                   "tools-raise",
                                   "tools-raise-to-top", GDK_SHIFT_MASK,
                                   NULL);

  tool_view->lower_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
                                   "tools-lower",
                                   "tools-lower-to-bottom", GDK_SHIFT_MASK,
                                    NULL);

  tool_view->reset_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
                                   "tools-reset", NULL);

  if (view_type == GIMP_VIEW_TYPE_LIST)
    {
      GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view);
      GtkWidget             *tree_widget = GTK_WIDGET (tree_view);
      GtkTreeViewColumn     *column;
      GtkCellRenderer       *eye_cell;
      GtkIconSize            icon_size;

      column = gtk_tree_view_column_new ();
      gtk_tree_view_insert_column (tree_view->view, column, 0);

      eye_cell = gimp_cell_renderer_toggle_new (GIMP_STOCK_VISIBLE);

      icon_size = gimp_get_icon_size (GTK_WIDGET (tree_view),
                                      GIMP_STOCK_VISIBLE,
                                      GTK_ICON_SIZE_BUTTON,
                                      view_size -
                                      2 * tree_widget->style->xthickness,
                                      view_size -
                                      2 * tree_widget->style->ythickness);
      g_object_set (eye_cell, "stock-size", icon_size, NULL);

      gtk_tree_view_column_pack_start (column, eye_cell, FALSE);
      gtk_tree_view_column_set_cell_data_func  (column, eye_cell,
                                                gimp_tool_view_eye_data_func,
                                                tree_view,
                                                NULL);

      tree_view->toggle_cells = g_list_prepend (tree_view->toggle_cells,
                                                eye_cell);

      g_signal_connect (eye_cell, "clicked",
                        G_CALLBACK (gimp_tool_view_eye_clicked),
                        tree_view);

      tool_view->visible_handler_id =
        gimp_container_add_handler (container, "notify::visible",
                                    G_CALLBACK (gimp_tool_view_visible_notify),
                                    tree_view);
    }

  gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor);

  return GTK_WIDGET (tool_view);
}