Commit 684591f8 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

added a name label (with properties to show/hide and to set it).

2005-05-27  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpeditor.[ch]: added a name label (with properties
	to show/hide and to set it).

	* app/widgets/gimpcontainergridview.[ch]
	* app/widgets/gimphistogrameditor.[ch]: removed the label here and
	use the functionality now provided by GimpEditor instead.

	* app/widgets/gimpcontainerpopup.c: changed accordingly.
parent 337947de
2005-05-27 Sven Neumann <sven@gimp.org>
* app/widgets/gimpeditor.[ch]: added a name label (with properties
to show/hide and to set it).
* app/widgets/gimpcontainergridview.[ch]
* app/widgets/gimphistogrameditor.[ch]: removed the label here and
use the functionality now provided by GimpEditor instead.
* app/widgets/gimpcontainerpopup.c: changed accordingly.
2005-05-27 Sven Neumann <sven@gimp.org>
* app/widgets/gimphistogrameditor.c: use a smaller font for the
statistics.
2005-05-27 Sven Neumann <sven@gimp.org>
* app/core/gimpdata.c: reverted previous change for now.
......
......@@ -203,15 +203,7 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box->scrolled_win),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
grid_view->name_label = gtk_label_new (_("(None)"));
gtk_misc_set_alignment (GTK_MISC (grid_view->name_label), 0.0, 0.5);
gimp_label_set_attributes (GTK_LABEL (grid_view->name_label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_box_pack_start (GTK_BOX (grid_view), grid_view->name_label,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (grid_view), grid_view->name_label, 0);
gtk_widget_show (grid_view->name_label);
gimp_editor_set_show_name (GIMP_EDITOR (grid_view), TRUE);
grid_view->wrap_box = gtk_hwrap_box_new (FALSE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (box->scrolled_win),
......@@ -494,8 +486,7 @@ gimp_container_grid_view_rename_item (GimpContainerView *view,
{
gchar *name = gimp_viewable_get_description (viewable, NULL);
gtk_label_set_text (GTK_LABEL (grid_view->name_label), name);
gimp_editor_set_name (GIMP_EDITOR (view), name);
g_free (name);
}
}
......@@ -649,12 +640,12 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view,
gimp_view_renderer_update (preview->renderer);
name = gimp_viewable_get_description (preview->renderer->viewable, NULL);
gtk_label_set_text (GTK_LABEL (grid_view->name_label), name);
gimp_editor_set_name (GIMP_EDITOR (grid_view), name);
g_free (name);
}
else
{
gtk_label_set_text (GTK_LABEL (grid_view->name_label), _("(None)"));
gimp_editor_set_name (GIMP_EDITOR (grid_view), NULL);
}
grid_view->selected_item = preview;
......
......@@ -40,7 +40,6 @@ struct _GimpContainerGridView
{
GimpContainerBox parent_instance;
GtkWidget *name_label;
GtkWidget *wrap_box;
gint rows;
......
......@@ -490,8 +490,8 @@ gimp_container_popup_create_view (GimpContainerPopup *popup)
10 * (popup->default_preview_size +
2 * popup->preview_border_width));
if (GIMP_IS_CONTAINER_GRID_VIEW (popup->editor->view))
gtk_widget_hide (GIMP_CONTAINER_GRID_VIEW (popup->editor->view)->name_label);
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));
......
......@@ -34,6 +34,8 @@
#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
#define DEFAULT_CONTENT_SPACING 2
#define DEFAULT_BUTTON_SPACING 2
......@@ -46,7 +48,9 @@ enum
PROP_MENU_FACTORY,
PROP_MENU_IDENTIFIER,
PROP_UI_PATH,
PROP_POPUP_DATA
PROP_POPUP_DATA,
PROP_SHOW_NAME,
PROP_NAME
};
......@@ -160,6 +164,19 @@ gimp_editor_class_init (GimpEditorClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_SHOW_NAME,
g_param_spec_boolean ("show-name",
NULL, NULL,
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name",
NULL, NULL,
NULL,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("content_spacing",
NULL, NULL,
......@@ -193,6 +210,16 @@ gimp_editor_init (GimpEditor *editor)
editor->ui_path = NULL;
editor->popup_data = editor;
editor->button_box = NULL;
editor->name_label = g_object_new (GTK_TYPE_LABEL,
"xalign", 0.0,
"yalign", 0.5,
"ellipsize", PANGO_ELLIPSIZE_END,
NULL);
gimp_label_set_attributes (GTK_LABEL (editor->name_label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_box_pack_start (GTK_BOX (editor), editor->name_label, FALSE, FALSE, 0);
}
static void
......@@ -250,6 +277,12 @@ gimp_editor_set_property (GObject *object,
case PROP_POPUP_DATA:
editor->popup_data = g_value_get_pointer (value);
break;
case PROP_SHOW_NAME:
g_object_set_property (G_OBJECT (editor->name_label), "visible", value);
break;
case PROP_NAME:
gimp_editor_set_name (editor, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -278,6 +311,9 @@ gimp_editor_get_property (GObject *object,
case PROP_POPUP_DATA:
g_value_set_pointer (value, editor->popup_data);
break;
case PROP_SHOW_NAME:
g_object_get_property (G_OBJECT (editor->name_label), "visible", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -662,6 +698,25 @@ gimp_editor_add_action_button (GimpEditor *editor,
return button;
}
void
gimp_editor_set_show_name (GimpEditor *editor,
gboolean show)
{
g_return_if_fail (GIMP_IS_EDITOR (editor));
g_object_set (editor, "show-name", show, NULL);
}
void
gimp_editor_set_name (GimpEditor *editor,
const gchar *name)
{
g_return_if_fail (GIMP_IS_EDITOR (editor));
gtk_label_set_text (GTK_LABEL (editor->name_label),
name ? name : _("(None)"));
}
void
gimp_editor_set_box_style (GimpEditor *editor,
GtkBox *box)
......
......@@ -46,6 +46,7 @@ struct _GimpEditor
gchar *ui_path;
gpointer popup_data;
GtkWidget *name_label;
GtkWidget *button_box;
};
......@@ -86,6 +87,11 @@ GtkWidget * gimp_editor_add_action_button (GimpEditor *editor,
const gchar *action_name,
...);
void gimp_editor_set_show_name (GimpEditor *editor,
gboolean show);
void gimp_editor_set_name (GimpEditor *editor,
const gchar *name);
void gimp_editor_set_box_style (GimpEditor *editor,
GtkBox *box);
......
......@@ -138,13 +138,7 @@ gimp_histogram_editor_init (GimpHistogramEditor *editor)
editor->idle_id = 0;
editor->box = gimp_histogram_box_new ();
editor->name = label = gtk_label_new (_("(None)"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gimp_label_set_attributes (GTK_LABEL (editor->name),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_box_pack_start (GTK_BOX (editor), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gimp_editor_set_show_name (GIMP_EDITOR (editor), TRUE);
view = GIMP_HISTOGRAM_BOX (editor->box)->view;
......@@ -196,15 +190,21 @@ gimp_histogram_editor_init (GimpHistogramEditor *editor)
gint y = (i % 3);
label = gtk_label_new (gettext (gimp_histogram_editor_labels[i]));
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
-1);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1,
GTK_FILL, GTK_FILL, 2, 2);
GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 2);
gtk_widget_show (label);
editor->labels[i] = label = gtk_label_new (NULL);
gimp_label_set_attributes (GTK_LABEL (editor->labels[i]),
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
-1);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, x + 1, x + 2, y, y + 1,
GTK_FILL, GTK_FILL, 2, 2);
GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 2);
gtk_widget_show (label);
}
}
......@@ -316,7 +316,7 @@ static void
gimp_histogram_editor_layer_changed (GimpImage *gimage,
GimpHistogramEditor *editor)
{
const gchar *name;
const gchar *name = NULL;
if (editor->drawable)
{
......@@ -347,19 +347,14 @@ gimp_histogram_editor_layer_changed (GimpImage *gimage,
gimp_histogram_editor_update (editor);
}
else
else if (editor->histogram)
{
name = _("(None)");
if (editor->histogram)
{
gimp_histogram_calculate (editor->histogram, NULL, NULL);
gtk_widget_queue_draw GTK_WIDGET (editor->box);
gimp_histogram_editor_info_update (editor);
}
gimp_histogram_calculate (editor->histogram, NULL, NULL);
gtk_widget_queue_draw GTK_WIDGET (editor->box);
gimp_histogram_editor_info_update (editor);
}
gtk_label_set_text (GTK_LABEL (editor->name), name);
gimp_editor_set_name (GIMP_EDITOR (editor), name);
}
static void
......
......@@ -42,7 +42,6 @@ struct _GimpHistogramEditor
guint idle_id;
GtkWidget *name;
GtkWidget *menu;
GtkWidget *box;
GtkWidget *labels[6];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment