[gthumb] toolbox: use a grid layout for the buttons
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] toolbox: use a grid layout for the buttons
- Date: Sat, 9 Nov 2013 20:06:35 +0000 (UTC)
commit c4370dabbff012ca076c2f303e6cee320481841a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Oct 30 21:47:53 2013 +0100
toolbox: use a grid layout for the buttons
.../file_tools/gth-file-tool-adjust-colors.c | 2 +-
.../file_tools/gth-file-tool-adjust-contrast.c | 2 +-
extensions/file_tools/gth-file-tool-crop.c | 2 +-
extensions/file_tools/gth-file-tool-equalize.c | 2 +-
extensions/file_tools/gth-file-tool-flip.c | 2 +-
extensions/file_tools/gth-file-tool-grayscale.c | 5 +-
extensions/file_tools/gth-file-tool-mirror.c | 2 +-
extensions/file_tools/gth-file-tool-negative.c | 2 +-
extensions/file_tools/gth-file-tool-redo.c | 2 +-
extensions/file_tools/gth-file-tool-resize.c | 2 +-
extensions/file_tools/gth-file-tool-rotate-left.c | 2 +-
extensions/file_tools/gth-file-tool-rotate-right.c | 2 +-
extensions/file_tools/gth-file-tool-rotate.c | 3 +-
extensions/file_tools/gth-file-tool-save-as.c | 2 +-
extensions/file_tools/gth-file-tool-save.c | 2 +-
extensions/file_tools/gth-file-tool-sharpen.c | 5 +-
extensions/file_tools/gth-file-tool-undo.c | 2 +-
extensions/red_eye_removal/gth-file-tool-red-eye.c | 2 +-
extensions/resize_images/callbacks.c | 2 +-
gthumb/gth-file-tool.c | 47 +++----
gthumb/gth-file-tool.h | 36 +++---
gthumb/gth-toolbox.c | 130 +++++++++++++++-----
gthumb/gth-toolbox.h | 8 ++
23 files changed, 165 insertions(+), 101 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-adjust-colors.c
b/extensions/file_tools/gth-file-tool-adjust-colors.c
index 06a5aa7..9359953 100644
--- a/extensions/file_tools/gth-file-tool-adjust-colors.c
+++ b/extensions/file_tools/gth-file-tool-adjust-colors.c
@@ -580,7 +580,7 @@ gth_file_tool_adjust_colors_init (GthFileToolAdjustColors *self)
self->priv->builder = NULL;
self->priv->image_task = NULL;
- gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-adjust-colors", _("Adjust Colors..."), _("Adjust
Colors"), FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-adjust-colors-symbolic", _("Adjust Colors"),
GTH_TOOLBOX_SECTION_COLORS);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Change brightness, contrast, saturation and gamma
level of the image"));
}
diff --git a/extensions/file_tools/gth-file-tool-adjust-contrast.c
b/extensions/file_tools/gth-file-tool-adjust-contrast.c
index 6665e64..ef8f36d 100644
--- a/extensions/file_tools/gth-file-tool-adjust-contrast.c
+++ b/extensions/file_tools/gth-file-tool-adjust-contrast.c
@@ -241,7 +241,7 @@ gth_file_tool_adjust_contrast_activate (GthFileTool *base)
static void
gth_file_tool_adjust_contrast_init (GthFileToolAdjustContrast *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-adjust-contrast", _("Adjust Contrast"), NULL,
TRUE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-adjust-contrast-symbolic", _("Adjust
Contrast"), GTH_TOOLBOX_SECTION_COLORS);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Automatic contrast adjustment"));
}
diff --git a/extensions/file_tools/gth-file-tool-crop.c b/extensions/file_tools/gth-file-tool-crop.c
index a68a4f0..2442966 100644
--- a/extensions/file_tools/gth-file-tool-crop.c
+++ b/extensions/file_tools/gth-file-tool-crop.c
@@ -663,7 +663,7 @@ gth_file_tool_crop_init (GthFileToolCrop *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_FILE_TOOL_CROP, GthFileToolCropPrivate);
self->priv->settings = g_settings_new (GTHUMB_CROP_SCHEMA);
- gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-crop", _("Crop..."), _("Crop"), FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-crop-symbolic", _("Crop"),
GTH_TOOLBOX_SECTION_FORMAT);
}
diff --git a/extensions/file_tools/gth-file-tool-equalize.c b/extensions/file_tools/gth-file-tool-equalize.c
index 4a7f814..100606e 100644
--- a/extensions/file_tools/gth-file-tool-equalize.c
+++ b/extensions/file_tools/gth-file-tool-equalize.c
@@ -182,6 +182,6 @@ gth_file_tool_equalize_class_init (GthFileToolEqualizeClass *klass)
static void
gth_file_tool_equalize_init (GthFileToolEqualize *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "histogram", _("Equalize"), NULL, FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-equalize-symbolic", _("Equalize"),
GTH_TOOLBOX_SECTION_COLORS);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Equalize image histogram"));
}
diff --git a/extensions/file_tools/gth-file-tool-flip.c b/extensions/file_tools/gth-file-tool-flip.c
index 1c60a27..95c3811 100644
--- a/extensions/file_tools/gth-file-tool-flip.c
+++ b/extensions/file_tools/gth-file-tool-flip.c
@@ -87,6 +87,6 @@ gth_file_tool_flip_class_init (GthFileToolFlipClass *klass)
static void
gth_file_tool_flip_init (GthFileToolFlip *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "object-flip-vertical-symbolic", _("Flip"), NULL,
FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-flip-vertical-symbolic", _("Flip"),
GTH_TOOLBOX_SECTION_ROTATION);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Flip the image vertically"));
}
diff --git a/extensions/file_tools/gth-file-tool-grayscale.c b/extensions/file_tools/gth-file-tool-grayscale.c
index 6da8637..434a7b8 100644
--- a/extensions/file_tools/gth-file-tool-grayscale.c
+++ b/extensions/file_tools/gth-file-tool-grayscale.c
@@ -470,8 +470,7 @@ gth_file_tool_grayscale_init (GthFileToolGrayscale *self)
self->priv->builder = NULL;
gth_file_tool_construct (GTH_FILE_TOOL (self),
- "tool-grayscale",
- _("Grayscale..."),
+ "image-grayscale-symbolic",
_("Grayscale"),
- FALSE);
+ GTH_TOOLBOX_SECTION_COLORS);
}
diff --git a/extensions/file_tools/gth-file-tool-mirror.c b/extensions/file_tools/gth-file-tool-mirror.c
index 5a2aeb2..0ae6cca 100644
--- a/extensions/file_tools/gth-file-tool-mirror.c
+++ b/extensions/file_tools/gth-file-tool-mirror.c
@@ -87,6 +87,6 @@ gth_file_tool_mirror_class_init (GthFileToolMirrorClass *klass)
static void
gth_file_tool_mirror_init (GthFileToolMirror *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "object-flip-horizontal-symbolic", _("Mirror"), NULL,
FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-flip-horizontal-symbolic", _("Mirror"),
GTH_TOOLBOX_SECTION_ROTATION);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Mirror the image horizontally"));
}
diff --git a/extensions/file_tools/gth-file-tool-negative.c b/extensions/file_tools/gth-file-tool-negative.c
index 7c34c8a..170aa3d 100644
--- a/extensions/file_tools/gth-file-tool-negative.c
+++ b/extensions/file_tools/gth-file-tool-negative.c
@@ -133,5 +133,5 @@ gth_file_tool_negative_class_init (GthFileToolNegativeClass *klass)
static void
gth_file_tool_negative_init (GthFileToolNegative *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-invert", _("Negative"), _("Negative"), FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-invert-symbolic", _("Negative"),
GTH_TOOLBOX_SECTION_COLORS);
}
diff --git a/extensions/file_tools/gth-file-tool-redo.c b/extensions/file_tools/gth-file-tool-redo.c
index 329ae32..95919cd 100644
--- a/extensions/file_tools/gth-file-tool-redo.c
+++ b/extensions/file_tools/gth-file-tool-redo.c
@@ -72,5 +72,5 @@ gth_file_tool_redo_class_init (GthFileToolRedoClass *klass)
static void
gth_file_tool_redo_init (GthFileToolRedo *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "redo", _("Redo"), _("Redo"), FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "edit-redo-symbolic", _("Redo"),
GTH_TOOLBOX_SECTION_FILE);
}
diff --git a/extensions/file_tools/gth-file-tool-resize.c b/extensions/file_tools/gth-file-tool-resize.c
index 7334b87..0e01692 100644
--- a/extensions/file_tools/gth-file-tool-resize.c
+++ b/extensions/file_tools/gth-file-tool-resize.c
@@ -811,5 +811,5 @@ gth_file_tool_resize_init (GthFileToolResize *self)
self->priv->builder = NULL;
self->priv->preview = NULL;
self->priv->new_image = NULL;
- gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-resize", _("Resize..."), _("Resize"), FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-resize-symbolic", _("Resize"),
GTH_TOOLBOX_SECTION_FORMAT);
}
diff --git a/extensions/file_tools/gth-file-tool-rotate-left.c
b/extensions/file_tools/gth-file-tool-rotate-left.c
index 03f69b9..e2414b8 100644
--- a/extensions/file_tools/gth-file-tool-rotate-left.c
+++ b/extensions/file_tools/gth-file-tool-rotate-left.c
@@ -87,6 +87,6 @@ gth_file_tool_rotate_left_class_init (GthFileToolRotateLeftClass *klass)
static void
gth_file_tool_rotate_left_init (GthFileToolRotateLeft *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "object-rotate-left-symbolic", _("Rotate Left"), NULL,
FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-rotate-left-symbolic", _("Rotate Left"),
GTH_TOOLBOX_SECTION_ROTATION);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Rotate the image by 90 degrees counterclockwise"));
}
diff --git a/extensions/file_tools/gth-file-tool-rotate-right.c
b/extensions/file_tools/gth-file-tool-rotate-right.c
index 2bbcf3b..f6eb5e8 100644
--- a/extensions/file_tools/gth-file-tool-rotate-right.c
+++ b/extensions/file_tools/gth-file-tool-rotate-right.c
@@ -87,6 +87,6 @@ gth_file_tool_rotate_right_class_init (GthFileToolRotateRightClass *klass)
static void
gth_file_tool_rotate_right_init (GthFileToolRotateRight *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "object-rotate-right-symbolic", _("Rotate Right"),
NULL, TRUE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-rotate-right-symbolic", _("Rotate Right"),
GTH_TOOLBOX_SECTION_ROTATION);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Rotate the image by 90 degrees clockwise"));
}
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index 8db38a8..c4a6d5e 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -654,6 +654,5 @@ gth_file_tool_rotate_init (GthFileToolRotate *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_FILE_TOOL_ROTATE, GthFileToolRotatePrivate);
self->priv->settings = g_settings_new (GTHUMB_ROTATE_SCHEMA);
- gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-rotate", _("Rotate..."), _("Rotate"), TRUE);
- gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Freely rotate the image"));
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-rotate-symbolic", _("Rotate"),
GTH_TOOLBOX_SECTION_ROTATION);
}
diff --git a/extensions/file_tools/gth-file-tool-save-as.c b/extensions/file_tools/gth-file-tool-save-as.c
index b77ac2c..e1cb272 100644
--- a/extensions/file_tools/gth-file-tool-save-as.c
+++ b/extensions/file_tools/gth-file-tool-save-as.c
@@ -67,5 +67,5 @@ gth_file_tool_save_as_class_init (GthFileToolSaveAsClass *klass)
static void
gth_file_tool_save_as_init (GthFileToolSaveAs *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), GTK_STOCK_SAVE_AS, _("Save As"), NULL, FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "document-save-as-symbolic", _("Save As"),
GTH_TOOLBOX_SECTION_FILE);
}
diff --git a/extensions/file_tools/gth-file-tool-save.c b/extensions/file_tools/gth-file-tool-save.c
index d339e53..a9c5850 100644
--- a/extensions/file_tools/gth-file-tool-save.c
+++ b/extensions/file_tools/gth-file-tool-save.c
@@ -63,5 +63,5 @@ gth_file_tool_save_class_init (GthFileToolSaveClass *klass)
static void
gth_file_tool_save_init (GthFileToolSave *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), GTK_STOCK_SAVE, _("Save"), _("Save"), FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "document-save-symbolic", _("Save"),
GTH_TOOLBOX_SECTION_FILE);
}
diff --git a/extensions/file_tools/gth-file-tool-sharpen.c b/extensions/file_tools/gth-file-tool-sharpen.c
index 043d065..3fe2264 100644
--- a/extensions/file_tools/gth-file-tool-sharpen.c
+++ b/extensions/file_tools/gth-file-tool-sharpen.c
@@ -410,8 +410,7 @@ gth_file_tool_sharpen_init (GthFileToolSharpen *self)
self->priv->show_preview = TRUE;
gth_file_tool_construct (GTH_FILE_TOOL (self),
- "tool-sharpen",
- _("Enhance Focus..."),
+ "image-sharpen-symbolic",
_("Enhance Focus"),
- FALSE);
+ GTH_TOOLBOX_SECTION_COLORS);
}
diff --git a/extensions/file_tools/gth-file-tool-undo.c b/extensions/file_tools/gth-file-tool-undo.c
index e392de4..d6dfc07 100644
--- a/extensions/file_tools/gth-file-tool-undo.c
+++ b/extensions/file_tools/gth-file-tool-undo.c
@@ -72,5 +72,5 @@ gth_file_tool_undo_class_init (GthFileToolUndoClass *klass)
static void
gth_file_tool_undo_init (GthFileToolUndo *self)
{
- gth_file_tool_construct (GTH_FILE_TOOL (self), "undo", _("Undo"), _("Undo"), TRUE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "edit-undo-symbolic", _("Undo"),
GTH_TOOLBOX_SECTION_FILE);
}
diff --git a/extensions/red_eye_removal/gth-file-tool-red-eye.c
b/extensions/red_eye_removal/gth-file-tool-red-eye.c
index ad17901..d1ca226 100644
--- a/extensions/red_eye_removal/gth-file-tool-red-eye.c
+++ b/extensions/red_eye_removal/gth-file-tool-red-eye.c
@@ -507,6 +507,6 @@ gth_file_tool_red_eye_init (GthFileToolRedEye *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_FILE_TOOL_RED_EYE, GthFileToolRedEyePrivate);
self->priv->new_pixbuf = NULL;
self->priv->is_red = NULL;
- gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-red-eye", _("Red Eye Removal..."), _("Red Eye
Removal"), FALSE);
+ gth_file_tool_construct (GTH_FILE_TOOL (self), "image-red-eye-symbolic", _("Red Eye Removal"),
GTH_TOOLBOX_SECTION_COLORS);
gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("Remove the red eye effect caused by camera
flashes"));
}
diff --git a/extensions/resize_images/callbacks.c b/extensions/resize_images/callbacks.c
index 0bd022c..6a890b2 100644
--- a/extensions/resize_images/callbacks.c
+++ b/extensions/resize_images/callbacks.c
@@ -34,7 +34,7 @@ static const GActionEntry actions[] = {
static const GthMenuEntry action_entries[] = {
- { N_("Resize Images..."), "win.resize-images" }
+ { N_("Resize Images..."), "win.resize-images", NULL, "image-resize-symbolic" }
};
diff --git a/gthumb/gth-file-tool.c b/gthumb/gth-file-tool.c
index 5ad39fc..3d1abfe 100644
--- a/gthumb/gth-file-tool.c
+++ b/gthumb/gth-file-tool.c
@@ -34,12 +34,11 @@ static guint gth_file_tool_signals[LAST_SIGNAL] = { 0 };
struct _GthFileToolPrivate {
- GtkWidget *window;
- const char *icon_name;
- const char *button_text;
- const char *options_title;
- gboolean separator;
- gboolean cancelled;
+ GtkWidget *window;
+ const char *icon_name;
+ const char *options_title;
+ GthToolboxSection section;
+ gboolean cancelled;
};
@@ -134,39 +133,35 @@ gth_file_tool_init (GthFileTool *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_FILE_TOOL, GthFileToolPrivate);
self->priv->icon_name = NULL;
- self->priv->button_text = NULL;
self->priv->options_title = NULL;
self->priv->cancelled = FALSE;
+ self->priv->section = GTH_TOOLBOX_SECTION_COLORS;
- gtk_button_set_relief (GTK_BUTTON (self), GTK_RELIEF_NONE);
+ /*gtk_button_set_relief (GTK_BUTTON (self), GTK_RELIEF_NONE);*/
}
void
-gth_file_tool_construct (GthFileTool *self,
- const char *icon_name,
- const char *button_text,
- const char *options_title,
- gboolean separator)
+gth_file_tool_construct (GthFileTool *self,
+ const char *icon_name,
+ const char *options_title,
+ GthToolboxSection section)
{
GtkWidget *hbox;
GtkWidget *icon;
- GtkWidget *label;
self->priv->icon_name = icon_name;
- self->priv->button_text = button_text;
self->priv->options_title = options_title;
- self->priv->separator = separator;
+ self->priv->section = section;
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
gtk_widget_show (icon);
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
- label = gtk_label_new (button_text);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), options_title);
gtk_widget_show (hbox);
gtk_container_add (GTK_CONTAINER (self), hbox);
@@ -247,17 +242,17 @@ gth_file_tool_get_options (GthFileTool *self)
}
-const char *
-gth_file_tool_get_options_title (GthFileTool *self)
+GthToolboxSection
+gth_file_tool_get_section (GthFileTool *self)
{
- return self->priv->options_title;
+ return self->priv->section;
}
-gboolean
-gth_file_tool_has_separator (GthFileTool *self)
+const char *
+gth_file_tool_get_options_title (GthFileTool *self)
{
- return self->priv->separator;
+ return self->priv->options_title;
}
diff --git a/gthumb/gth-file-tool.h b/gthumb/gth-file-tool.h
index 37fa4f4..6663237 100644
--- a/gthumb/gth-file-tool.h
+++ b/gthumb/gth-file-tool.h
@@ -23,6 +23,7 @@
#define GTH_FILE_TOOL_H
#include <gtk/gtk.h>
+#include "gth-toolbox.h"
G_BEGIN_DECLS
@@ -59,24 +60,23 @@ struct _GthFileToolClass {
void (*hide_options) (GthFileTool *self);
};
-GType gth_file_tool_get_type (void);
-void gth_file_tool_construct (GthFileTool *self,
- const char *icon_name,
- const char *button_text,
- const char *options_title,
- gboolean separator);
-GtkWidget * gth_file_tool_get_window (GthFileTool *self);
-const char * gth_file_tool_get_icon_name (GthFileTool *self);
-void gth_file_tool_activate (GthFileTool *self);
-void gth_file_tool_cancel (GthFileTool *self);
-gboolean gth_file_tool_is_cancelled (GthFileTool *self);
-void gth_file_tool_update_sensitivity (GthFileTool *self);
-GtkWidget * gth_file_tool_get_options (GthFileTool *self);
-const char * gth_file_tool_get_options_title (GthFileTool *self);
-gboolean gth_file_tool_has_separator (GthFileTool *self);
-void gth_file_tool_destroy_options (GthFileTool *self);
-void gth_file_tool_show_options (GthFileTool *self);
-void gth_file_tool_hide_options (GthFileTool *self);
+GType gth_file_tool_get_type (void);
+void gth_file_tool_construct (GthFileTool *self,
+ const char *icon_name,
+ const char *options_title,
+ GthToolboxSection section);
+GtkWidget * gth_file_tool_get_window (GthFileTool *self);
+const char * gth_file_tool_get_icon_name (GthFileTool *self);
+void gth_file_tool_activate (GthFileTool *self);
+void gth_file_tool_cancel (GthFileTool *self);
+gboolean gth_file_tool_is_cancelled (GthFileTool *self);
+void gth_file_tool_update_sensitivity (GthFileTool *self);
+GtkWidget * gth_file_tool_get_options (GthFileTool *self);
+const char * gth_file_tool_get_options_title (GthFileTool *self);
+GthToolboxSection gth_file_tool_get_section (GthFileTool *self);
+void gth_file_tool_destroy_options (GthFileTool *self);
+void gth_file_tool_show_options (GthFileTool *self);
+void gth_file_tool_hide_options (GthFileTool *self);
G_END_DECLS
diff --git a/gthumb/gth-toolbox.c b/gthumb/gth-toolbox.c
index 02f6d75..51ca385 100644
--- a/gthumb/gth-toolbox.c
+++ b/gthumb/gth-toolbox.c
@@ -29,6 +29,8 @@
#define GTH_TOOLBOX_PAGE_TOOLS "GthToolbox.Tools"
#define GTH_TOOLBOX_PAGE_OPTIONS "GthToolbox.Options"
+#define GRID_COLUMNS 4
+#define GRID_SPACING 20
enum {
@@ -39,7 +41,7 @@ enum {
struct _GthToolboxPrivate {
char *name;
- GtkWidget *box;
+ GtkWidget *tool_grid[GTH_TOOLBOX_N_SECTIONS];
GtkWidget *options;
GtkWidget *options_icon;
GtkWidget *options_title;
@@ -117,15 +119,26 @@ gth_toolbox_class_init (GthToolboxClass *klass)
}
+static const char * section_title[] = {
+ NULL,
+ N_("Colors"),
+ N_("Rotation"),
+ N_("Format")
+};
+
+
static void
gth_toolbox_init (GthToolbox *toolbox)
{
GtkWidget *scrolled;
+ int i;
+ GtkWidget *grid_box;
GtkWidget *options_box;
GtkWidget *options_header;
GtkWidget *header_align;
toolbox->priv = G_TYPE_INSTANCE_GET_PRIVATE (toolbox, GTH_TYPE_TOOLBOX, GthToolboxPrivate);
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (toolbox)),
GTK_STYLE_CLASS_SIDEBAR);
/* tool list page */
@@ -137,10 +150,43 @@ gth_toolbox_init (GthToolbox *toolbox)
gtk_widget_show (scrolled);
gtk_stack_add_named (GTK_STACK (toolbox), scrolled, GTH_TOOLBOX_PAGE_TOOLS);
- toolbox->priv->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_set_spacing (GTK_BOX (toolbox->priv->box), 0);
- gtk_widget_show (toolbox->priv->box);
- gtk_container_add (GTK_CONTAINER (scrolled), toolbox->priv->box);
+ grid_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_add (GTK_CONTAINER (scrolled), grid_box);
+ gtk_widget_set_margin_top (grid_box, GRID_SPACING * 2);
+ gtk_widget_set_halign (grid_box, GTK_ALIGN_CENTER);
+
+ for (i = 0; i < GTH_TOOLBOX_N_SECTIONS; i++) {
+ GtkWidget *box;
+
+ if (i > 0) {
+ PangoAttrList *attrs;
+ GtkWidget *label;
+
+ attrs = pango_attr_list_new ();
+ pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
+
+ label = gtk_label_new (_(section_title[i]));
+ gtk_label_set_attributes (GTK_LABEL (label), attrs);
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_widget_set_margin_bottom (label, GRID_SPACING);
+ gtk_box_pack_start (GTK_BOX (grid_box), label, FALSE, FALSE, 0);
+
+ pango_attr_list_unref (attrs);
+ }
+ toolbox->priv->tool_grid[i] = gtk_grid_new ();
+ gtk_widget_set_margin_bottom (toolbox->priv->tool_grid[i], GRID_SPACING);
+ gtk_style_context_add_class (gtk_widget_get_style_context (toolbox->priv->tool_grid[i]),
"toolbox");
+ gtk_grid_set_row_spacing (GTK_GRID (toolbox->priv->tool_grid[i]), GRID_SPACING);
+ gtk_grid_set_column_spacing (GTK_GRID (toolbox->priv->tool_grid[i]), GRID_SPACING);
+ gtk_grid_set_column_homogeneous (GTK_GRID (toolbox->priv->tool_grid[i]), TRUE);
+ gtk_grid_set_row_homogeneous (GTK_GRID (toolbox->priv->tool_grid[i]), TRUE);
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (box), toolbox->priv->tool_grid[i], FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (grid_box), box, FALSE, FALSE, 0);
+ }
+ gtk_widget_show_all (grid_box);
/* tool options page */
@@ -200,7 +246,7 @@ child_show_options_cb (GtkWidget *tool,
markup = g_markup_printf_escaped ("<span size='large' weight='bold'>%s</span>",
gth_file_tool_get_options_title (GTH_FILE_TOOL (tool)));
gtk_label_set_markup (GTK_LABEL (toolbox->priv->options_title), markup);
- gtk_image_set_from_icon_name (GTK_IMAGE (toolbox->priv->options_icon), gth_file_tool_get_icon_name
(GTH_FILE_TOOL (tool)), GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_image_set_from_icon_name (GTK_IMAGE (toolbox->priv->options_icon), gth_file_tool_get_icon_name
(GTH_FILE_TOOL (tool)), GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (toolbox->priv->options), options);
gtk_stack_set_visible_child_name (GTK_STACK (toolbox), GTH_TOOLBOX_PAGE_OPTIONS);
@@ -231,14 +277,22 @@ _gth_toolbox_add_children (GthToolbox *toolbox)
{
GArray *children;
int i;
+ int row[GTH_TOOLBOX_N_SECTIONS];
+ int column[GTH_TOOLBOX_N_SECTIONS];
children = gth_main_get_type_set (toolbox->priv->name);
if (children == NULL)
return;
+ for (i = 0; i < GTH_TOOLBOX_N_SECTIONS; i++) {
+ row[i] = 0;
+ column[i] = -1;
+ }
+
for (i = 0; i < children->len; i++) {
GType child_type;
GtkWidget *child;
+ int section;
child_type = g_array_index (children, GType, i);
child = g_object_new (child_type, NULL);
@@ -247,15 +301,17 @@ _gth_toolbox_add_children (GthToolbox *toolbox)
g_signal_connect (child, "hide-options", G_CALLBACK (child_hide_options_cb), toolbox);
gtk_widget_show (child);
- if (gth_file_tool_has_separator (GTH_FILE_TOOL (child))) {
- GtkWidget *separator;
-
- separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show (separator);
- gtk_box_pack_start (GTK_BOX (toolbox->priv->box), separator, FALSE, FALSE, 0);
+ section = gth_file_tool_get_section (GTH_FILE_TOOL (child));
+ column[section] = column[section] + 1;
+ if (column[section] == GRID_COLUMNS) {
+ column[section] = 0;
+ row[section] = row[section] + 1;
}
- gtk_box_pack_start (GTK_BOX (toolbox->priv->box), child, FALSE, FALSE, 0);
+ gtk_grid_attach (GTK_GRID (toolbox->priv->tool_grid[section]),
+ child,
+ column[section], row[section],
+ 1, 1);
}
}
@@ -275,20 +331,24 @@ gth_toolbox_new (const char *name)
void
gth_toolbox_update_sensitivity (GthToolbox *toolbox)
{
- GList *children;
- GList *scan;
+ int i;
- children = gtk_container_get_children (GTK_CONTAINER (toolbox->priv->box));
- for (scan = children; scan; scan = scan->next) {
- GtkWidget *child = scan->data;
+ for (i = 0; i < GTH_TOOLBOX_N_SECTIONS; i++) {
+ GList *children;
+ GList *scan;
- if (! GTH_IS_FILE_TOOL (child))
- continue;
+ children = gtk_container_get_children (GTK_CONTAINER (toolbox->priv->tool_grid[i]));
+ for (scan = children; scan; scan = scan->next) {
+ GtkWidget *child = scan->data;
- gth_file_tool_update_sensitivity (GTH_FILE_TOOL (child));
- }
+ if (! GTH_IS_FILE_TOOL (child))
+ continue;
+
+ gth_file_tool_update_sensitivity (GTH_FILE_TOOL (child));
+ }
- g_list_free (children);
+ g_list_free (children);
+ }
}
@@ -312,20 +372,24 @@ gth_toolbox_get_tool (GthToolbox *toolbox,
GType tool_type)
{
GtkWidget *tool = NULL;
- GList *children;
- GList *scan;
+ int i;
+
+ for (i = 0; (tool == NULL) && (i < GTH_TOOLBOX_N_SECTIONS); i++) {
+ GList *children;
+ GList *scan;
- children = gtk_container_get_children (GTK_CONTAINER (toolbox->priv->box));
- for (scan = children; scan; scan = scan->next) {
- GtkWidget *child = scan->data;
+ children = gtk_container_get_children (GTK_CONTAINER (toolbox->priv->tool_grid[i]));
+ for (scan = children; scan; scan = scan->next) {
+ GtkWidget *child = scan->data;
- if (G_OBJECT_TYPE (child) == tool_type) {
- tool = child;
- break;
+ if (G_OBJECT_TYPE (child) == tool_type) {
+ tool = child;
+ break;
+ }
}
- }
- g_list_free (children);
+ g_list_free (children);
+ }
return tool;
}
diff --git a/gthumb/gth-toolbox.h b/gthumb/gth-toolbox.h
index 61e33e6..c409c00 100644
--- a/gthumb/gth-toolbox.h
+++ b/gthumb/gth-toolbox.h
@@ -26,6 +26,14 @@
G_BEGIN_DECLS
+typedef enum {
+ GTH_TOOLBOX_SECTION_FILE,
+ GTH_TOOLBOX_SECTION_COLORS,
+ GTH_TOOLBOX_SECTION_ROTATION,
+ GTH_TOOLBOX_SECTION_FORMAT,
+ GTH_TOOLBOX_N_SECTIONS
+} GthToolboxSection;
+
#define GTH_TYPE_TOOLBOX (gth_toolbox_get_type ())
#define GTH_TOOLBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_TOOLBOX, GthToolbox))
#define GTH_TOOLBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_TOOLBOX, GthToolboxClass))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]