static void
gimp_container_popup_create_view (GimpContainerPopup *popup)
{
  GimpEditor *editor;
  GtkWidget  *button;

  popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, NULL);
  gimp_container_editor_construct (popup->editor,
                                   popup->view_type,
                                   popup->container,
                                   popup->context,
                                   popup->view_size,
                                   popup->view_border_width,
                                   NULL, NULL, NULL);

  gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (popup->editor->view),
                                       FALSE);

  gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (popup->editor->view),
                                       6  * (popup->default_view_size +
                                             2 * popup->view_border_width),
                                       10 * (popup->default_view_size +
                                             2 * popup->view_border_width));

  if (GIMP_IS_EDITOR (popup->editor->view))
    gimp_editor_set_show_name (GIMP_EDITOR (popup->editor->view), FALSE);

  gtk_container_add (GTK_CONTAINER (popup->frame), GTK_WIDGET (popup->editor));
  gtk_widget_show (GTK_WIDGET (popup->editor));

  editor = GIMP_EDITOR (popup->editor->view);

  gimp_editor_add_button (editor, GTK_STOCK_ZOOM_OUT,
                          _("Smaller Previews"), NULL,
                          G_CALLBACK (gimp_container_popup_smaller_clicked),
                          NULL,
                          popup);
  gimp_editor_add_button (editor, GTK_STOCK_ZOOM_IN,
                          _("Larger Previews"), NULL,
                          G_CALLBACK (gimp_container_popup_larger_clicked),
                          NULL,
                          popup);

  button = gimp_editor_add_stock_box (editor, GIMP_TYPE_VIEW_TYPE, "gimp",
                                      G_CALLBACK (gimp_container_popup_view_type_toggled),
                                      popup);
  gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), popup->view_type);

  if (popup->dialog_factory)
    gimp_editor_add_button (editor, popup->dialog_stock_id,
                            popup->dialog_tooltip, NULL,
                            G_CALLBACK (gimp_container_popup_dialog_clicked),
                            NULL,
                            popup);

  gtk_widget_grab_focus (GTK_WIDGET (popup->editor));
}
Beispiel #2
0
GtkWidget *
gimp_font_view_new (GimpViewType     view_type,
                    GimpContainer   *container,
                    GimpContext     *context,
                    gint             view_size,
                    gint             view_border_width,
                    GimpMenuFactory *menu_factory)
{
  GimpFontView        *font_view;
  GimpContainerEditor *editor;

  g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (view_size > 0 &&
                        view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
  g_return_val_if_fail (view_border_width >= 0 &&
                        view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
                        NULL);
  g_return_val_if_fail (menu_factory == NULL ||
                        GIMP_IS_MENU_FACTORY (menu_factory), NULL);

  font_view = g_object_new (GIMP_TYPE_FONT_VIEW,
                            "view-type",         view_type,
                            "container",         container,
                            "context",           context,
                            "view-size",         view_size,
                            "view-border-width", view_border_width,
                            "menu-factory",      menu_factory,
                            "menu-identifier",   "<Fonts>",
                            "ui-path",           "/fonts-popup",
                            NULL);

  editor = GIMP_CONTAINER_EDITOR (font_view);

  gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view),
                                       FALSE);

  font_view->refresh_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "fonts",
                                   "fonts-refresh", NULL);

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

  return GTK_WIDGET (font_view);
}
gboolean
gimp_container_editor_construct (GimpContainerEditor *editor,
                                 GimpViewType         view_type,
                                 GimpContainer       *container,
                                 GimpContext         *context,
                                 gint                 view_size,
                                 gint                 view_border_width,
                                 GimpMenuFactory     *menu_factory,
                                 const gchar         *menu_identifier,
                                 const gchar         *ui_identifier)
{
    g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE);
    g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
    g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
    g_return_val_if_fail (view_size > 0 &&
                          view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE);
    g_return_val_if_fail (view_border_width >= 0 &&
                          view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
                          FALSE);
    g_return_val_if_fail (menu_factory == NULL ||
                          GIMP_IS_MENU_FACTORY (menu_factory), FALSE);

    switch (view_type)
    {
    case GIMP_VIEW_TYPE_GRID:
#if 0
        editor->view =
            GIMP_CONTAINER_VIEW (gimp_container_icon_view_new (container,
                                 context,
                                 view_size,
                                 view_border_width));
#else
        editor->view =
            GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (container,
                                 context,
                                 view_size,
                                 view_border_width));
#endif
        break;

    case GIMP_VIEW_TYPE_LIST:
        editor->view =
            GIMP_CONTAINER_VIEW (gimp_container_tree_view_new (container,
                                 context,
                                 view_size,
                                 view_border_width));
        break;

    default:
        g_warning ("%s: unknown GimpViewType passed", G_STRFUNC);
        return FALSE;
    }

    if (GIMP_IS_LIST (container))
        gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view),
                                             ! GIMP_LIST (container)->sort_func);

    if (menu_factory && menu_identifier && ui_identifier)
        gimp_editor_create_menu (GIMP_EDITOR (editor->view),
                                 menu_factory, menu_identifier, ui_identifier,
                                 editor);

    gtk_box_pack_start (GTK_BOX (editor), GTK_WIDGET (editor->view),
                        TRUE, TRUE, 0);
    gtk_widget_show (GTK_WIDGET (editor->view));

    g_signal_connect_object (editor->view, "select-item",
                             G_CALLBACK (gimp_container_editor_select_item),
                             editor, 0);
    g_signal_connect_object (editor->view, "activate-item",
                             G_CALLBACK (gimp_container_editor_activate_item),
                             editor, 0);
    g_signal_connect_object (editor->view, "context-item",
                             G_CALLBACK (gimp_container_editor_context_item),
                             editor, 0);

    {
        GimpObject *object = gimp_context_get_by_type (context,
                             gimp_container_get_children_type (container));

        gimp_container_editor_select_item (GTK_WIDGET (editor->view),
                                           (GimpViewable *) object, NULL,
                                           editor);
    }

    return TRUE;
}
Beispiel #4
0
static void
gimp_container_popup_create_view (GimpContainerPopup *popup)
{
  GimpEditor *editor;
  GtkWidget  *button;

  popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR,
                                "view-type",         popup->view_type,
                                "container",         popup->container,
                                "context",           popup->context,
                                "view-size",         popup->view_size,
                                "view-border-width", popup->view_border_width,
                                NULL);

  gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (popup->editor->view),
                                       FALSE);

  if (popup->view_type == GIMP_VIEW_TYPE_LIST)
    {
      GtkWidget *search_entry;

      search_entry = gtk_entry_new ();
      gtk_box_pack_end (GTK_BOX (popup->editor->view), search_entry,
                        FALSE, FALSE, 0);
      gtk_tree_view_set_search_entry (GTK_TREE_VIEW (GIMP_CONTAINER_TREE_VIEW (GIMP_CONTAINER_VIEW (popup->editor->view))->view),
                                      GTK_ENTRY (search_entry));
      gtk_widget_show (search_entry);
    }

  gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (popup->editor->view),
                                       6  * (popup->default_view_size +
                                             2 * popup->view_border_width),
                                       10 * (popup->default_view_size +
                                             2 * popup->view_border_width));

  if (GIMP_IS_EDITOR (popup->editor->view))
    gimp_editor_set_show_name (GIMP_EDITOR (popup->editor->view), FALSE);

  gtk_container_add (GTK_CONTAINER (popup->frame), GTK_WIDGET (popup->editor));
  gtk_widget_show (GTK_WIDGET (popup->editor));

  editor = GIMP_EDITOR (popup->editor->view);

  gimp_editor_add_button (editor, "zoom-out",
                          _("Smaller Previews"), NULL,
                          G_CALLBACK (gimp_container_popup_smaller_clicked),
                          NULL,
                          popup);
  gimp_editor_add_button (editor, "zoom-in",
                          _("Larger Previews"), NULL,
                          G_CALLBACK (gimp_container_popup_larger_clicked),
                          NULL,
                          popup);

  button = gimp_editor_add_icon_box (editor, GIMP_TYPE_VIEW_TYPE, "gimp",
                                     G_CALLBACK (gimp_container_popup_view_type_toggled),
                                     popup);
  gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), popup->view_type);

  if (popup->dialog_factory)
    gimp_editor_add_button (editor, popup->dialog_icon_name,
                            popup->dialog_tooltip, NULL,
                            G_CALLBACK (gimp_container_popup_dialog_clicked),
                            NULL,
                            popup);

  gtk_widget_grab_focus (GTK_WIDGET (popup->editor));
}