Commit a08d648a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

added a stock icon for "view-zoom-1-1".

2004-05-10  Sven Neumann  <sven@gimp.org>

	* app/actions/view-actions.c: added a stock icon for "view-zoom-1-1".

	* app/widgets/gimpunitcombobox.[ch]: added functions to get and
	set the active unit.

	* app/widgets/gimpunitstore.c (gimp_unit_store_tree_model_get_value):
	need to special case GIMP_UNIT_PIXEL.

	* app/display/Makefile.am
	* app/display/display-types.h
	* app/display/gimpscalecombobox.[ch]: new widget to be used in the
	display's statusbar.

	* app/display/gimpdisplayshell-cursor.[ch]: always display the
	cursor position, not only if the cursor is inside the image. Added
	new function gimp_display_shell_clear_cursor() to clear the cursor
	label.

	* app/display/gimpdisplayshell-callbacks.c: changed accordingly.

	* app/display/gimpstatusbar.[ch]
	* app/display/gimpdisplayshell.c
	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell-scale.c: do not explicitely resize
	the statusbar cursor label, connect to GimpDisplayShell::scaled
	instead. Added a GimpScaleComboBox to the status bar.
parent da0de087
2004-05-10 Sven Neumann <sven@gimp.org>
* app/actions/view-actions.c: added a stock icon for "view-zoom-1-1".
* app/widgets/gimpunitcombobox.[ch]: added functions to get and
set the active unit.
* app/widgets/gimpunitstore.c (gimp_unit_store_tree_model_get_value):
need to special case GIMP_UNIT_PIXEL.
* app/display/Makefile.am
* app/display/display-types.h
* app/display/gimpscalecombobox.[ch]: new widget to be used in the
display's statusbar.
* app/display/gimpdisplayshell-cursor.[ch]: always display the
cursor position, not only if the cursor is inside the image. Added
new function gimp_display_shell_clear_cursor() to clear the cursor
label.
* app/display/gimpdisplayshell-callbacks.c: changed accordingly.
* app/display/gimpstatusbar.[ch]
* app/display/gimpdisplayshell.c
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell-scale.c: do not explicitely resize
the statusbar cursor label, connect to GimpDisplayShell::scaled
instead. Added a GimpScaleComboBox to the status bar.
2004-05-10 Michael Natterer <mitch@gimp.org>
Started making the toolbox configurable.
......
......@@ -204,7 +204,7 @@ static GimpRadioActionEntry view_zoom_actions[] =
20000,
GIMP_HELP_VIEW_ZOOM_IN },
{ "view-zoom-1-1", NULL,
{ "view-zoom-1-1", GTK_STOCK_ZOOM_100,
N_("1:1 (100%)"), "1", NULL,
10000,
GIMP_HELP_VIEW_ZOOM_100 },
......
......@@ -64,6 +64,8 @@ libappdisplay_a_sources = \
gimpnavigationview.h \
gimpprogress.c \
gimpprogress.h \
gimpscalecombobox.c \
gimpscalecombobox.h \
gimpstatusbar.c \
gimpstatusbar.h
......
......@@ -31,6 +31,7 @@ typedef struct _GimpDisplay GimpDisplay;
typedef struct _GimpDisplayShell GimpDisplayShell;
typedef struct _GimpNavigationView GimpNavigationView;
typedef struct _GimpScaleComboBox GimpScaleComboBox;
typedef struct _GimpStatusbar GimpStatusbar;
typedef struct _Selection Selection;
......
......@@ -67,7 +67,6 @@
#include "gimpdisplayshell-title.h"
#include "gimpdisplayshell-transform.h"
#include "gimpnavigationview.h"
#include "gimpstatusbar.h"
#include "gimp-intl.h"
......@@ -281,8 +280,6 @@ gimp_display_shell_canvas_realize (GtkWidget *canvas,
gimp_display_shell_get_padding (shell, &padding_mode, &padding_color);
gimp_display_shell_set_padding (shell, padding_mode, &padding_color);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_update_title (shell);
shell->disp_width = canvas->allocation.width;
......@@ -532,7 +529,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
return TRUE;
shell->proximity = FALSE;
gimp_display_shell_update_cursor (shell, -1, -1, -1, -1);
gimp_display_shell_clear_cursor (shell);
tool_manager_oper_update_active (gimp,
&image_coords, state,
......@@ -548,7 +545,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_PROXIMITY_OUT:
shell->proximity = FALSE;
gimp_display_shell_update_cursor (shell, -1, -1, -1, -1);
gimp_display_shell_clear_cursor (shell);
tool_manager_oper_update_active (gimp,
&image_coords, state,
......@@ -1076,8 +1073,10 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
switch (kevent->keyval)
{
case GDK_Left: case GDK_Right:
case GDK_Up: case GDK_Down:
case GDK_Left:
case GDK_Right:
case GDK_Up:
case GDK_Down:
if (! gimp_image_is_empty (gimage))
{
tool_manager_arrow_key_active (gimp,
......@@ -1153,8 +1152,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
break;
/* Update the state based on modifiers being pressed */
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Control_L: case GDK_Control_R:
{
GdkModifierType key;
......@@ -1210,8 +1209,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
break;
/* Update the state based on modifiers being pressed */
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Control_L: case GDK_Control_R:
{
GdkModifierType key;
......@@ -1280,13 +1279,11 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
}
if (update_cursor)
{
gimp_display_shell_update_cursor (shell,
RINT (display_coords.x),
RINT (display_coords.y),
RINT (image_coords.x),
RINT (image_coords.y));
}
gimp_display_shell_update_cursor (shell,
RINT (display_coords.x),
RINT (display_coords.y),
RINT (image_coords.x),
RINT (image_coords.y));
return return_val;
}
......
......@@ -147,8 +147,8 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
/* use the passed image_coords for the statusbar because they are
* possibly snapped...
*/
gimp_statusbar_update_cursor (GIMP_STATUSBAR (shell->statusbar),
image_x, image_y);
gimp_statusbar_set_cursor (GIMP_STATUSBAR (shell->statusbar),
image_x, image_y);
/* ...but use the unsnapped display_coords for the info window */
if (display_x >= 0 && display_y >= 0)
......@@ -168,6 +168,16 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
}
}
void
gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gimp_statusbar_clear_cursor (GIMP_STATUSBAR (shell->statusbar));
info_window_update_extended (shell->gdisp, -1, -1);
}
static void
gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
GdkCursorType cursor_type,
......
......@@ -33,6 +33,7 @@ void gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint display_y,
gint image_x,
gint image_y);
void gimp_display_shell_clear_cursor (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_CURSOR_H__ */
......@@ -42,7 +42,6 @@
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-title.h"
#include "gimpstatusbar.h"
#define GIMP_DISPLAY_UPDATE_ICON_TIMEOUT 1000
......@@ -398,8 +397,6 @@ static void
gimp_display_shell_size_changed_handler (GimpImage *gimage,
GimpDisplayShell *shell)
{
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_scale_resize (shell,
GIMP_DISPLAY_CONFIG (gimage->gimp->config)->resize_windows_on_resize,
TRUE);
......@@ -411,8 +408,6 @@ gimp_display_shell_resolution_changed_handler (GimpImage *gimage,
{
gimp_display_shell_scale_setup (shell);
gimp_display_shell_scaled (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
}
static void
......@@ -421,8 +416,6 @@ gimp_display_shell_unit_changed_handler (GimpImage *gimage,
{
gimp_display_shell_scale_setup (shell);
gimp_display_shell_scaled (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
}
static void
......@@ -580,8 +573,6 @@ gimp_display_shell_monitor_res_notify_handler (GObject *config,
gimp_display_shell_scale_setup (shell);
gimp_display_shell_scaled (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_expose_full (shell);
}
}
......
......@@ -40,7 +40,6 @@
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-title.h"
#include "gimpstatusbar.h"
#include "gimp-intl.h"
......@@ -340,8 +339,6 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
shell->dot_for_dot = dot_for_dot;
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_scale_resize (shell,
GIMP_DISPLAY_CONFIG (gimp->config)->resize_windows_on_zoom,
TRUE);
......
......@@ -971,9 +971,9 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell)
gimp_display_shell_connect (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_scale_setup (shell);
gimp_display_shell_expose_full (shell);
gimp_display_shell_scaled (shell);
g_signal_emit (shell, display_shell_signals[RECONNECT], 0);
}
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscalecombobox.c
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "display-types.h"
#include "gimpscalecombobox.h"
#define MAX_ITEMS 10
enum
{
SCALE,
LABEL,
PERSISTENT,
NUM_COLUMNS
};
static void gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass);
static void gimp_scale_combo_box_init (GimpScaleComboBox *combo_box);
static void gimp_scale_combo_box_finalize (GObject *object);
static GtkComboBoxClass *parent_class = NULL;
GType
gimp_scale_combo_box_get_type (void)
{
static GType combo_box_type = 0;
if (!combo_box_type)
{
static const GTypeInfo combo_box_info =
{
sizeof (GimpScaleComboBoxClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_scale_combo_box_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpScaleComboBox),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_scale_combo_box_init
};
combo_box_type = g_type_register_static (GTK_TYPE_COMBO_BOX,
"GimpScaleComboBox",
&combo_box_info, 0);
}
return combo_box_type;
}
static void
gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_scale_combo_box_finalize;
}
static void
gimp_scale_combo_box_init (GimpScaleComboBox *combo_box)
{
GtkListStore *store;
GtkCellRenderer *cell;
GtkTreeIter iter;
gint i;
store = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_DOUBLE,
G_TYPE_STRING,
G_TYPE_BOOLEAN);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
g_object_unref (store);
cell = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
"xalign", 1.0,
NULL);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
"text", LABEL,
NULL);
for (i = 8; i > 0; i /= 2)
{
gchar label[32];
g_snprintf (label, sizeof (label), "%d%%", i * 100);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
SCALE, (gdouble) i,
LABEL, label,
PERSISTENT, TRUE,
-1);
}
for (i = 2; i <= 8; i *= 2)
{
gchar label[32];
g_snprintf (label, sizeof (label), "%d%%", 100 / i);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
SCALE, 1.0 / (gdouble) i,
LABEL, label,
PERSISTENT, TRUE,
-1);
}
}
static void
gimp_scale_combo_box_finalize (GObject *object)
{
GimpScaleComboBox *combo_box = GIMP_SCALE_COMBO_BOX (object);
if (combo_box->mru)
{
g_list_foreach (combo_box->mru,
(GFunc) gtk_tree_row_reference_free, NULL);
g_list_free (combo_box->mru);
combo_box->mru = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_scale_combo_box_mru_add (GimpScaleComboBox *combo_box,
GtkTreeIter *iter)
{
GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
GtkTreePath *path = gtk_tree_model_get_path (model, iter);
GList *list;
gboolean found;
for (list = combo_box->mru, found = FALSE; list && !found; list = list->next)
{
GtkTreePath *this = gtk_tree_row_reference_get_path (list->data);
if (gtk_tree_path_compare (this, path) == 0)
{
if (list->prev)
{
combo_box->mru = g_list_remove_link (combo_box->mru, list);
combo_box->mru = g_list_concat (list, combo_box->mru);
}
found = TRUE;
}
gtk_tree_path_free (this);
}
if (! found)
combo_box->mru = g_list_prepend (combo_box->mru,
gtk_tree_row_reference_new (model, path));
gtk_tree_path_free (path);
}
static void
gimp_scale_combo_box_mru_remove_last (GimpScaleComboBox *combo_box)
{
GtkTreeModel *model;
GtkTreePath *path;
GList *last;
GtkTreeIter iter;
if (! combo_box->mru)
return;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
last = g_list_last (combo_box->mru);
path = gtk_tree_row_reference_get_path (last->data);
if (gtk_tree_model_get_iter (model, &iter, path))
{
gchar *label;
gtk_tree_model_get (model, &iter,
LABEL, &label,
-1);
g_printerr ("removing %s\n", label);
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
gtk_tree_row_reference_free (last->data);
combo_box->mru = g_list_delete_link (combo_box->mru, last);
}
gtk_tree_path_free (path);
}
/**
* gimp_scale_combo_box_new:
*
* Return value: a new #GimpScaleComboBox.
**/
GtkWidget *
gimp_scale_combo_box_new (void)
{
return g_object_new (GIMP_TYPE_SCALE_COMBO_BOX, NULL);
}
void
gimp_scale_combo_box_set_scale (GimpScaleComboBox *combo_box,
gdouble scale)
{
GtkTreeModel *model;
GtkListStore *store;
GtkTreeIter iter;
gboolean iter_valid;
gboolean persistent;
g_return_if_fail (GIMP_IS_SCALE_COMBO_BOX (combo_box));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
store = GTK_LIST_STORE (model);
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
iter_valid;
iter_valid = gtk_tree_model_iter_next (model, &iter))
{
gdouble this;
gtk_tree_model_get (model, &iter,
SCALE, &this,
-1);
if (this == scale)
break;
}
if (! iter_valid)
{
GtkTreeIter sibling;
gchar label[32];
for (iter_valid = gtk_tree_model_get_iter_first (model, &sibling);
iter_valid;
iter_valid = gtk_tree_model_iter_next (model, &sibling))
{
gdouble this;
gtk_tree_model_get (model, &sibling,
SCALE, &this,
-1);
if (this < scale)
break;
}
g_snprintf (label, sizeof (label), "%d%%", (gint) (100.0 * scale));
gtk_list_store_insert_before (store, &iter,
iter_valid ? &sibling : NULL);
gtk_list_store_set (store, &iter,
SCALE, scale,
LABEL, label,
PERSISTENT, FALSE,
-1);
}
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
gtk_tree_model_get (model, &iter,
PERSISTENT, &persistent,
-1);
if (! persistent)
{
gimp_scale_combo_box_mru_add (combo_box, &iter);
if (gtk_tree_model_iter_n_children (model, NULL) > MAX_ITEMS)
gimp_scale_combo_box_mru_remove_last (combo_box);
}
}
gdouble
gimp_scale_combo_box_get_scale (GimpScaleComboBox *combo_box)
{
GtkTreeIter iter;
gdouble scale = 1.0;
g_return_val_if_fail (GIMP_IS_SCALE_COMBO_BOX (combo_box), FALSE);
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
{
gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)),
&iter,
SCALE, &scale,
-1);
}
return scale;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscalecombobox.h
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_SCALE_COMBO_BOX_H__
#define __GIMP_SCALE_COMBO_BOX_H__
#include <gtk/gtkcombobox.h>
#define GIMP_TYPE_SCALE_COMBO_BOX (gimp_scale_combo_box_get_type ())
#define GIMP_SCALE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SCALE_COMBO_BOX, GimpScaleComboBox))
#define GIMP_SCALE_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SCALE_COMBO_BOX, GimpScaleComboBoxClass))
#define GIMP_IS_SCALE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SCALE_COMBO_BOX))
#define GIMP_IS_SCALE_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SCALE_COMBO_BOX))
#define GIMP_SCALE_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SCALE_COMBO_BOX, GimpScaleComboBoxClass))