/*
- * (GLABELS) Label and Business Card Creation program for GNOME
+ * ui-property-bar.c
+ * Copyright (C) 2003-2009 Jim Evins <evins@snaught.com>.
*
- * property-bar.c: gLabels property bar
+ * This file is part of gLabels.
*
- * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
- *
- * This program is free software; you can redistribute it and/or modify
+ * gLabels 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
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * gLabels 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
+ * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
-#include <libgnomeprint/gnome-font.h>
-
#include "ui-property-bar.h"
-#include "ui-util.h"
-#include "mygal/widget-color-combo.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtkbuilder.h>
+#include <gtk/gtkspinbutton.h>
+#include <gtk/gtktoolbar.h>
+#include <gtk/gtktoggletoolbutton.h>
+#include <string.h>
+
+#include "util.h"
+#include "font-combo.h"
+#include "color-combo-button.h"
#include "stock-pixmaps/stockpixbufs.h"
#include "prefs.h"
#include "color.h"
#include "debug.h"
-/*============================================================================*/
-/* Private macros and constants. */
-/*============================================================================*/
-
-/*============================================================================*/
-/* Private globals */
-/*============================================================================*/
-
-static GObjectClass *parent_class;
-
-static gchar* doc_verbs [] = {
- "/commands/PropFontName",
- "/commands/PropFontSize",
- "/commands/PropFontBold",
- "/commands/PropFontItalic",
- "/commands/PropTextAlignLeft",
- "/commands/PropTextAlignCenter",
- "/commands/PropTextAlignRight",
- "/commands/PropFillColor",
- "/commands/PropLineColor",
- "/commands/PropTextColor",
- "/commands/PropLineWidth",
-
- NULL
-};
-static gchar* text_verbs [] = {
- "/commands/PropFontName",
- "/commands/PropFontSize",
- "/commands/PropFontBold",
- "/commands/PropFontItalic",
- "/commands/PropTextAlignLeft",
- "/commands/PropTextAlignCenter",
- "/commands/PropTextAlignRight",
- "/commands/PropTextColor",
-
- NULL
-};
+/*===========================================================================*/
+/* Private macros and constants. */
+/*===========================================================================*/
-static gchar* fill_verbs [] = {
- "/commands/PropFillColor",
- NULL
-};
+/*===========================================================================*/
+/* Private data types */
+/*===========================================================================*/
-static gchar* line_color_verbs [] = {
- "/commands/PropLineColor",
+struct _glUIPropertyBarPrivate {
- NULL
-};
+ glView *view;
-static gchar* line_width_verbs [] = {
- "/commands/PropLineWidth",
+ GtkBuilder *builder;
- NULL
+ GtkWidget *tool_bar;
+
+ /* Font selection */
+ GtkWidget *font_family_eventbox;
+ GtkWidget *font_family_combo;
+ GtkWidget *font_size_spin;
+ GtkWidget *font_bold_toggle;
+ GtkWidget *font_italic_toggle;
+
+ /* Text alignemnt radios */
+ GtkWidget *text_align_left_radio;
+ GtkWidget *text_align_center_radio;
+ GtkWidget *text_align_right_radio;
+
+ /* Color combos */
+ GtkWidget *text_color_eventbox;
+ GtkWidget *text_color_button;
+ GtkWidget *fill_color_eventbox;
+ GtkWidget *fill_color_button;
+ GtkWidget *line_color_eventbox;
+ GtkWidget *line_color_button;
+
+ /* Line width */
+ GtkWidget *line_width_spin;
+
+ /* Prevent recursion */
+ gboolean stop_signals;
};
-/*============================================================================*/
-/* Local function prototypes */
-/*============================================================================*/
+/*===========================================================================*/
+/* Private globals */
+/*===========================================================================*/
+
+
+/*===========================================================================*/
+/* Local function prototypes */
+/*===========================================================================*/
-static void gl_ui_property_bar_class_init (glUIPropertyBarClass *class);
-static void gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar);
static void gl_ui_property_bar_finalize (GObject *object);
-static void gl_ui_property_bar_construct (glUIPropertyBar *property_bar,
- BonoboUIComponent *ui_component);
+static void gl_ui_property_bar_construct (glUIPropertyBar *this);
-static void selection_changed_cb (glView *view,
- glUIPropertyBar *property_bar);
+static void selection_changed_cb (glUIPropertyBar *this);
-static void font_family_changed_cb (GtkEntry *entry,
- glUIPropertyBar *property_bar);
+static void font_family_changed_cb (GtkComboBox *combo,
+ glUIPropertyBar *this);
static void font_size_changed_cb (GtkSpinButton *spin,
- glUIPropertyBar *property_bar);
+ glUIPropertyBar *this);
-static void text_color_changed_cb (ColorCombo *cc,
- GdkColor *gdk_color,
- gboolean custom,
- gboolean by_user,
+static void text_color_changed_cb (glColorComboButton *cc,
+ guint color,
gboolean is_default,
- glUIPropertyBar *property_bar);
+ glUIPropertyBar *this);
-static void fill_color_changed_cb (ColorCombo *cc,
- GdkColor *gdk_color,
- gboolean custom,
- gboolean by_user,
+static void fill_color_changed_cb (glColorComboButton *cc,
+ guint color,
gboolean is_default,
- glUIPropertyBar *property_bar);
+ glUIPropertyBar *this);
-static void line_color_changed_cb (ColorCombo *cc,
- GdkColor *gdk_color,
- gboolean custom,
- gboolean by_user,
+static void line_color_changed_cb (glColorComboButton *cc,
+ guint color,
gboolean is_default,
- glUIPropertyBar *property_bar);
+ glUIPropertyBar *this);
static void line_width_changed_cb (GtkSpinButton *spin,
- glUIPropertyBar *property_bar);
+ glUIPropertyBar *this);
+
+static void font_bold_toggled_cb (GtkToggleToolButton *toggle,
+ glUIPropertyBar *this);
+
+static void font_italic_toggled_cb (GtkToggleToolButton *toggle,
+ glUIPropertyBar *this);
+
+static void text_align_toggled_cb (GtkToggleToolButton *toggle,
+ glUIPropertyBar *this);
+
+static void set_doc_items_sensitive (glUIPropertyBar *this,
+ gboolean state);
-static void prop_item_toggled_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- glUIPropertyBar *property_bar);
+static void set_text_items_sensitive (glUIPropertyBar *this,
+ gboolean state);
-static void null_cmd (BonoboUIComponent *ui_component,
- gpointer user_data,
- const gchar *verbname);
+static void set_fill_items_sensitive (glUIPropertyBar *this,
+ gboolean state);
+static void set_line_color_items_sensitive (glUIPropertyBar *this,
+ gboolean state);
+
+static void set_line_width_items_sensitive (glUIPropertyBar *this,
+ gboolean state);
-\f
/****************************************************************************/
/* Boilerplate Object stuff. */
/****************************************************************************/
-guint
-gl_ui_property_bar_get_type (void)
-{
- static guint property_bar_type = 0;
-
- if (!property_bar_type) {
- GTypeInfo property_bar_info = {
- sizeof (glUIPropertyBarClass),
- NULL,
- NULL,
- (GClassInitFunc) gl_ui_property_bar_class_init,
- NULL,
- NULL,
- sizeof (glUIPropertyBar),
- 0,
- (GInstanceInitFunc) gl_ui_property_bar_instance_init,
- };
-
- property_bar_type =
- g_type_register_static (G_TYPE_OBJECT,
- "glUIPropertyBar",
- &property_bar_info, 0);
- }
+G_DEFINE_TYPE (glUIPropertyBar, gl_ui_property_bar, GTK_TYPE_HBOX);
- return property_bar_type;
-}
static void
gl_ui_property_bar_class_init (glUIPropertyBarClass *class)
{
- GObjectClass *object_class = (GObjectClass *) class;
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
gl_debug (DEBUG_PROPERTY_BAR, "START");
- parent_class = g_type_class_peek_parent (class);
+ gl_ui_property_bar_parent_class = g_type_class_peek_parent (class);
object_class->finalize = gl_ui_property_bar_finalize;
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
+
static void
-gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar)
+gl_ui_property_bar_init (glUIPropertyBar *this)
{
gl_debug (DEBUG_PROPERTY_BAR, "START");
- property_bar->view = NULL;
+ this->priv = g_new0 (glUIPropertyBarPrivate, 1);
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
+
static void
gl_ui_property_bar_finalize (GObject *object)
{
- glUIPropertyBar *property_bar;
+ glUIPropertyBar *this = GL_UI_PROPERTY_BAR (object);
gl_debug (DEBUG_PROPERTY_BAR, "START");
g_return_if_fail (object != NULL);
g_return_if_fail (GL_IS_UI_PROPERTY_BAR (object));
- property_bar = GL_UI_PROPERTY_BAR (object);
-
- if (property_bar->view) {
- g_object_unref (G_OBJECT(property_bar->view));
- property_bar = NULL;
+ if (this->priv->view)
+ {
+ g_object_unref (G_OBJECT(this->priv->view));
}
+ if (this->priv->builder)
+ {
+ g_object_unref (G_OBJECT(this->priv->builder));
+ }
+ g_free (this->priv);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gl_ui_property_bar_parent_class)->finalize (object);
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
+
/****************************************************************************/
/* Create a NEW property_bar. */
/****************************************************************************/
-GObject *
-gl_ui_property_bar_new (BonoboUIComponent *ui_component)
+GtkWidget *
+gl_ui_property_bar_new (void)
{
- glUIPropertyBar *property_bar;
+ glUIPropertyBar *this;
gl_debug (DEBUG_PROPERTY_BAR, "START");
- property_bar = g_object_new (gl_ui_property_bar_get_type (), NULL);
+ this = g_object_new (GL_TYPE_UI_PROPERTY_BAR, NULL);
- gl_ui_property_bar_construct (property_bar, ui_component);
+ gl_ui_property_bar_construct (this);
gl_debug (DEBUG_PROPERTY_BAR, "END");
- return G_OBJECT(property_bar);
+ return GTK_WIDGET (this);
}
+
/******************************************************************************/
/* Initialize property toolbar. */
/******************************************************************************/
static void
-gl_ui_property_bar_construct (glUIPropertyBar *property_bar,
- BonoboUIComponent *ui_component)
+gl_ui_property_bar_construct (glUIPropertyBar *this)
{
- GtkWidget *wcombo;
- GList *family_names = NULL;
- GtkObject *adjust;
- ColorGroup *cg;
- GdkPixbuf *pixbuf;
- gchar *good_font_family;
- GdkColor *gdk_color;
+ GtkBuilder *builder;
+ static gchar *object_ids[] = { "property_toolbar",
+ "adjustment1", "adjustment2",
+ NULL };
+ GError *error = NULL;
+ GdkPixbuf *pixbuf = NULL;
gl_debug (DEBUG_PROPERTY_BAR, "START");
- property_bar->ui_component = ui_component;
+ this->priv->stop_signals = TRUE;
- /* Font family entry widget */
- wcombo = gtk_combo_new ();
- family_names = gnome_font_family_list ();
- gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), family_names);
- property_bar->font_family_entry = GTK_COMBO (wcombo)->entry;
- gtk_combo_set_value_in_list (GTK_COMBO(wcombo), TRUE, FALSE);
- gtk_entry_set_editable (GTK_ENTRY (property_bar->font_family_entry), FALSE);
- gtk_widget_set_size_request (wcombo, 200, -1);
-
- /* Make sure we have a valid font family. if not provide a good default. */
- if (g_list_find_custom (family_names,
- gl_prefs->default_font_family,
- (GCompareFunc)g_utf8_collate)) {
- good_font_family = g_strdup (gl_prefs->default_font_family);
- } else {
- if (family_names != NULL) {
- good_font_family = g_strdup (family_names->data); /* 1st entry */
- } else {
- good_font_family = NULL;
- }
+ builder = gtk_builder_new ();
+ gtk_builder_add_objects_from_file (builder,
+ GLABELS_BUILDER_DIR "property-bar.builder",
+ object_ids,
+ &error);
+ if (error) {
+ g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
+ g_error_free (error);
+ return;
}
- gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry), good_font_family);
- g_free (good_font_family);
- gnome_font_family_list_free (family_names);
- g_signal_connect (G_OBJECT (property_bar->font_family_entry),
- "changed", G_CALLBACK (font_family_changed_cb), property_bar);
+ gl_util_get_builder_widgets (builder,
+ "property_toolbar", &this->priv->tool_bar,
+ "font_family_eventbox", &this->priv->font_family_eventbox,
+ "font_size_spin", &this->priv->font_size_spin,
+ "font_bold_toggle", &this->priv->font_bold_toggle,
+ "font_italic_toggle", &this->priv->font_italic_toggle,
+ "text_align_left_radio", &this->priv->text_align_left_radio,
+ "text_align_center_radio", &this->priv->text_align_center_radio,
+ "text_align_right_radio", &this->priv->text_align_right_radio,
+ "text_color_eventbox", &this->priv->text_color_eventbox,
+ "fill_color_eventbox", &this->priv->fill_color_eventbox,
+ "line_color_eventbox", &this->priv->line_color_eventbox,
+ "line_width_spin", &this->priv->line_width_spin,
+ NULL);
+
+ gtk_container_add (GTK_CONTAINER (this), this->priv->tool_bar);
+
+ this->priv->font_family_combo = gl_font_combo_new (gl_prefs->default_font_family);
+ gtk_container_add (GTK_CONTAINER (this->priv->font_family_eventbox),
+ this->priv->font_family_combo);
+
+ pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
+ this->priv->text_color_button =
+ gl_color_combo_button_new (pixbuf,
+ _("Default"),
+ GL_COLOR_TEXT_DEFAULT,
+ gl_prefs->default_text_color);
+ gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->text_color_button),
+ GTK_RELIEF_NONE);
+ g_object_unref (G_OBJECT (pixbuf));
+ gtk_container_add (GTK_CONTAINER (this->priv->text_color_eventbox),
+ this->priv->text_color_button);
+
+ pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
+ this->priv->fill_color_button =
+ gl_color_combo_button_new (pixbuf,
+ _("No Fill"),
+ GL_COLOR_NO_FILL,
+ gl_prefs->default_fill_color);
+ gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->fill_color_button),
+ GTK_RELIEF_NONE);
+ g_object_unref (G_OBJECT (pixbuf));
+ gtk_container_add (GTK_CONTAINER (this->priv->fill_color_eventbox),
+ this->priv->fill_color_button);
+
+ pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
+ this->priv->line_color_button =
+ gl_color_combo_button_new (pixbuf,
+ _("No Line"),
+ GL_COLOR_NO_LINE,
+ gl_prefs->default_line_color);
+ gl_color_combo_button_set_relief (GL_COLOR_COMBO_BUTTON(this->priv->line_color_button),
+ GTK_RELIEF_NONE);
+ g_object_unref (G_OBJECT (pixbuf));
+ gtk_container_add (GTK_CONTAINER (this->priv->line_color_eventbox),
+ this->priv->line_color_button);
+
+ /* Save reference to gui tree so we don't lose tooltips */
+ this->priv->builder = builder;
+
+ set_doc_items_sensitive (this, FALSE);
- gl_ui_util_insert_widget (ui_component, wcombo, "/PropertyToolbar/PropFontName");
+ /* Font family entry widget */
+ g_signal_connect (G_OBJECT (this->priv->font_family_combo),
+ "changed", G_CALLBACK (font_family_changed_cb), this);
/* Font size entry widget */
- adjust = gtk_adjustment_new (1.0, 1.0, 250.0, 1.0, 10.0, 10.0);
- property_bar->font_size_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust),
- 1.0, 0);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin),
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
gl_prefs->default_font_size);
- g_signal_connect (G_OBJECT (property_bar->font_size_spin),
- "changed", G_CALLBACK (font_size_changed_cb), property_bar);
+ g_signal_connect (G_OBJECT (this->priv->font_size_spin),
+ "changed", G_CALLBACK (font_size_changed_cb), this);
- gl_ui_util_insert_widget (ui_component, property_bar->font_size_spin,
- "/PropertyToolbar/PropFontSize");
/* Bold and Italic toggles */
- bonobo_ui_component_add_verb (ui_component, "PropFontBold", null_cmd, NULL);
- gl_ui_util_set_verb_state (ui_component, "/commands/PropFontBold",
- (gl_prefs->default_font_weight == GNOME_FONT_BOLD));
- bonobo_ui_component_add_listener (ui_component, "PropFontBold",
- (BonoboUIListenerFn)prop_item_toggled_cb,
- (gpointer)property_bar);
- bonobo_ui_component_add_verb (ui_component, "PropFontItalic", null_cmd, NULL);
- gl_ui_util_set_verb_state (ui_component, "/commands/PropFontItalic",
- gl_prefs->default_font_italic_flag);
- bonobo_ui_component_add_listener (ui_component, "PropFontItalic",
- (BonoboUIListenerFn)prop_item_toggled_cb,
- (gpointer)property_bar);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
+ (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD));
+ g_signal_connect (G_OBJECT (this->priv->font_bold_toggle),
+ "toggled", G_CALLBACK (font_bold_toggled_cb), this);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
+ gl_prefs->default_font_italic_flag);
+ g_signal_connect (G_OBJECT (this->priv->font_italic_toggle),
+ "toggled", G_CALLBACK (font_italic_toggled_cb), this);
+
/* Text alignment radio group */
- bonobo_ui_component_add_verb (ui_component, "PropTextAlignLeft", null_cmd, NULL);
- gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignLeft",
- (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT));
- bonobo_ui_component_add_listener (ui_component, "PropTextAlignLeft",
- (BonoboUIListenerFn)prop_item_toggled_cb,
- (gpointer)property_bar);
- bonobo_ui_component_add_verb (ui_component, "PropTextAlignCenter", null_cmd, NULL);
- gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignCenter",
- (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER));
- bonobo_ui_component_add_listener (ui_component, "PropTextAlignCenter",
- (BonoboUIListenerFn)prop_item_toggled_cb,
- (gpointer)property_bar);
- bonobo_ui_component_add_verb (ui_component, "PropTextAlignRight", null_cmd, NULL);
- gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignRight",
- (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT));
- bonobo_ui_component_add_listener (ui_component, "PropTextAlignRight",
- (BonoboUIListenerFn)prop_item_toggled_cb,
- (gpointer)property_bar);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
+ (gl_prefs->default_text_alignment == PANGO_ALIGN_LEFT));
+ g_signal_connect (G_OBJECT (this->priv->text_align_left_radio),
+ "toggled", G_CALLBACK (text_align_toggled_cb), this);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
+ (gl_prefs->default_text_alignment == PANGO_ALIGN_CENTER));
+ g_signal_connect (G_OBJECT (this->priv->text_align_center_radio),
+ "toggled", G_CALLBACK (text_align_toggled_cb), this);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
+ (gl_prefs->default_text_alignment == PANGO_ALIGN_RIGHT));
+ g_signal_connect (G_OBJECT (this->priv->text_align_right_radio),
+ "toggled", G_CALLBACK (text_align_toggled_cb), this);
/* Text color widget */
- cg = color_group_fetch ("text_color_group", ui_component);
- pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
- gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color);
- property_bar->text_color_combo = color_combo_new (pixbuf, _("Default"),
- gdk_color, cg);
- g_free (gdk_color);
-
- g_signal_connect (G_OBJECT (property_bar->text_color_combo),
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->text_color_button),
+ gl_prefs->default_text_color);
+ g_signal_connect (G_OBJECT (this->priv->text_color_button),
"color_changed",
- G_CALLBACK (text_color_changed_cb), property_bar);
-
- gl_ui_util_insert_widget (ui_component, property_bar->text_color_combo,
- "/PropertyToolbar/PropTextColor");
+ G_CALLBACK (text_color_changed_cb), this);
/* Fill color widget */
- cg = color_group_fetch ("fill_color_group", ui_component);
- pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
- gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color);
- property_bar->fill_color_combo = color_combo_new (pixbuf, _("No fill"),
- gdk_color, cg);
- g_free (gdk_color);
-
- g_signal_connect (G_OBJECT (property_bar->fill_color_combo),
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->fill_color_button),
+ gl_prefs->default_fill_color);
+ g_signal_connect (G_OBJECT (this->priv->fill_color_button),
"color_changed",
- G_CALLBACK (fill_color_changed_cb), property_bar);
-
- gl_ui_util_insert_widget (ui_component, property_bar->fill_color_combo,
- "/PropertyToolbar/PropFillColor");
+ G_CALLBACK (fill_color_changed_cb), this);
/* Line color widget */
- cg = color_group_fetch ("line_color_group", ui_component);
- pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
- gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color);
- property_bar->line_color_combo = color_combo_new (pixbuf, _("No line"),
- gdk_color, cg);
- g_free (gdk_color);
-
- g_signal_connect (G_OBJECT (property_bar->line_color_combo),
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->line_color_button),
+ gl_prefs->default_line_color);
+ g_signal_connect (G_OBJECT (this->priv->line_color_button),
"color_changed",
- G_CALLBACK (line_color_changed_cb), property_bar);
-
- gl_ui_util_insert_widget (ui_component, property_bar->line_color_combo,
- "/PropertyToolbar/PropLineColor");
+ G_CALLBACK (line_color_changed_cb), this);
/* Line width entry widget */
- adjust = gtk_adjustment_new (1.0, 0.25, 4.0, 0.25, 1.0, 1.0);
- property_bar->line_width_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 0.25, 2);
-
- g_signal_connect (G_OBJECT (property_bar->line_width_spin),
+ g_signal_connect (G_OBJECT (this->priv->line_width_spin),
"changed",
- G_CALLBACK (line_width_changed_cb), property_bar);
-
- gl_ui_util_insert_widget (ui_component, property_bar->line_width_spin,
- "/PropertyToolbar/PropLineWidth");
+ G_CALLBACK (line_width_changed_cb), this);
- gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
+ this->priv->stop_signals = FALSE;
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
+
+/****************************************************************************/
+/* Fill widgets with default values. */
+/****************************************************************************/
+static void
+reset_to_default_properties (glView *view,
+ glUIPropertyBar *this)
+{
+
+ gl_font_combo_set_family (GL_FONT_COMBO (this->priv->font_family_combo),
+ view->default_font_family);
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
+ view->default_font_size);
+
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
+ (view->default_font_weight == PANGO_WEIGHT_BOLD));
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
+ view->default_font_italic_flag);
+
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
+ (view->default_text_alignment == PANGO_ALIGN_LEFT));
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
+ (view->default_text_alignment == PANGO_ALIGN_CENTER));
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
+ (view->default_text_alignment == PANGO_ALIGN_RIGHT));
+
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON(this->priv->text_color_button),
+ view->default_text_color);
+
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON(this->priv->fill_color_button),
+ view->default_fill_color);
+
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON(this->priv->line_color_button),
+ view->default_line_color);
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->line_width_spin),
+ view->default_line_width);
+}
+
+
/****************************************************************************/
/* Set view associated with property_bar. */
/****************************************************************************/
void
-gl_ui_property_bar_set_view (glUIPropertyBar *property_bar,
+gl_ui_property_bar_set_view (glUIPropertyBar *this,
glView *view)
{
glLabel *label;
- GList *family_names;
- gchar *good_font_family;
- GdkColor *gdk_color;
gl_debug (DEBUG_PROPERTY_BAR, "START");
label = view->label;
g_return_if_fail (label && GL_IS_LABEL (label));
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, doc_verbs, TRUE);
-
- property_bar->view = GL_VIEW (g_object_ref (G_OBJECT (view)));
-
- /* Make sure we have a valid font family. if not provide a good default. */
- family_names = gnome_font_family_list ();
- if (g_list_find_custom (family_names,
- view->default_font_family,
- (GCompareFunc)g_utf8_collate)) {
- good_font_family = g_strdup (view->default_font_family);
- } else {
- if (family_names != NULL) {
- good_font_family = g_strdup (family_names->data); /* 1st entry */
- } else {
- good_font_family = NULL;
- }
- }
- gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry), good_font_family);
+ set_doc_items_sensitive (this, TRUE);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin),
- view->default_font_size);
+ this->priv->view = GL_VIEW (g_object_ref (G_OBJECT (view)));
- gl_ui_util_set_verb_state (property_bar->ui_component,
- "/commands/PropFontBold",
- (view->default_font_weight == GNOME_FONT_BOLD));
- gl_ui_util_set_verb_state (property_bar->ui_component,
- "/commands/PropFontItalic",
- view->default_font_italic_flag);
-
- gl_ui_util_set_verb_state (property_bar->ui_component,
- "/commands/PropTextAlignLeft",
- (view->default_text_alignment == GTK_JUSTIFY_LEFT));
- gl_ui_util_set_verb_state (property_bar->ui_component,
- "/commands/PropTextAlignCenter",
- (view->default_text_alignment == GTK_JUSTIFY_CENTER));
- gl_ui_util_set_verb_state (property_bar->ui_component,
- "/commands/PropTextAlignRight",
- (view->default_text_alignment == GTK_JUSTIFY_RIGHT));
-
- gdk_color = gl_color_to_gdk_color (view->default_text_color);
- color_combo_set_color (COLOR_COMBO(property_bar->text_color_combo), gdk_color);
- g_free (gdk_color);
-
- gdk_color = gl_color_to_gdk_color (view->default_fill_color);
- color_combo_set_color (COLOR_COMBO(property_bar->fill_color_combo), gdk_color);
- g_free (gdk_color);
-
- gdk_color = gl_color_to_gdk_color (view->default_line_color);
- color_combo_set_color (COLOR_COMBO(property_bar->line_color_combo), gdk_color);
- g_free (gdk_color);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->line_width_spin),
- view->default_line_width);
+ reset_to_default_properties (view, this);
- g_signal_connect (G_OBJECT(view), "selection_changed",
- G_CALLBACK(selection_changed_cb), property_bar);
+ g_signal_connect_swapped (G_OBJECT(view), "selection_changed",
+ G_CALLBACK(selection_changed_cb), this);
+
+ g_signal_connect_swapped (G_OBJECT(view->label), "changed",
+ G_CALLBACK(selection_changed_cb), this);
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. View "selection state changed" callback. */
/*---------------------------------------------------------------------------*/
-static void
-selection_changed_cb (glView *view,
- glUIPropertyBar *property_bar)
+static void
+update_text_properties (glView *view,
+ glUIPropertyBar *this)
{
- gl_debug (DEBUG_PROPERTY_BAR, "START");
+ gboolean can_text, is_first_object;
+ gboolean is_same_font_family, is_same_font_size;
+ gboolean is_same_text_color, is_same_is_italic;
+ gboolean is_same_is_bold, is_same_align;
+ GList *p;
+ glLabelObject *object;
+ gchar *selection_font_family, *font_family;
+ gdouble selection_font_size, font_size;
+ guint selection_text_color, text_color;
+ glColorNode *text_color_node;
+ gboolean selection_is_italic, is_italic;
+ gboolean selection_is_bold, is_bold;
+ PangoAlignment selection_align, align;
+
+ can_text = gl_view_can_selection_text (view);
+ set_text_items_sensitive (this, can_text);
+
+ if (!can_text)
+ return;
- g_return_if_fail (view && GL_IS_VIEW (view));
- g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+ is_same_is_italic =
+ is_same_is_bold =
+ is_same_align =
+ is_same_text_color =
+ is_same_font_size =
+ is_same_font_family = TRUE;
+ selection_font_family = NULL;
+ selection_font_size = -1;
+ selection_align = PANGO_ALIGN_LEFT;
+ selection_is_italic = TRUE;
+ selection_is_bold = TRUE;
+ selection_text_color = 0;
+
+ is_first_object = TRUE;
+
+ for (p = view->selected_object_list; p != NULL; p = p->next)
+ {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (!gl_label_object_can_text (object))
+ continue;
+
+ font_family = gl_label_object_get_font_family (object);
+ if (font_family != NULL)
+ {
+ if (selection_font_family == NULL)
+ {
+ selection_font_family = g_strdup (font_family);
+ }
+ else
+ {
+ if (strcmp (font_family, selection_font_family) != 0)
+ {
+ is_same_font_family = FALSE;
+ }
+ }
+ g_free (font_family);
+ }
+
+ font_size = gl_label_object_get_font_size (object);
+
+ text_color_node = gl_label_object_get_text_color (object);
+ if (text_color_node->field_flag)
+ {
+ /* If a merge field is set we use the default color for merged color*/
+ text_color = GL_COLOR_MERGE_DEFAULT;
+
+ }
+ else
+ {
+ text_color = text_color_node->color;
+ }
+ gl_color_node_free (&text_color_node);
+
+ is_italic = gl_label_object_get_font_italic_flag (object);
+ is_bold = gl_label_object_get_font_weight (object) == PANGO_WEIGHT_BOLD;
+ align = gl_label_object_get_text_alignment (object);
+
+ if (is_first_object)
+ {
+ selection_font_size = font_size;
+ selection_text_color = text_color;
+ selection_is_italic = is_italic;
+ selection_is_bold = is_bold;
+ selection_align = align;
+ }
+ else
+ {
+ if (font_size != selection_font_size)
+ is_same_font_size = FALSE;
+ if (text_color != selection_text_color)
+ is_same_text_color = FALSE;
+ if (is_italic != selection_is_italic)
+ is_same_is_italic = FALSE;
+ if (is_bold != selection_is_bold)
+ is_same_is_bold = FALSE;
+ if (align != selection_align)
+ is_same_align = FALSE;
+ }
+ is_first_object = FALSE;
+ }
- if (gl_view_is_selection_empty (view)) {
+ if (is_same_font_family && (selection_font_family != NULL))
+ gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s",
+ selection_font_family);
+ gl_font_combo_set_family (GL_FONT_COMBO (this->priv->font_family_combo),
+ is_same_font_family?selection_font_family:"");
+ g_free (selection_font_family);
+
+ if (is_same_font_size)
+ {
+ gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g",
+ selection_font_size);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (this->priv->font_size_spin),
+ selection_font_size);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (this->priv->font_size_spin), "");
+ }
- /* No selection: make all controls active. */
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
- doc_verbs, TRUE);
+ if (is_same_text_color)
+ {
+ gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->text_color_button),
+ selection_text_color);
+ }
- } else {
+ if (is_same_is_italic)
+ {
+ gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d",
+ selection_is_italic);
+ }
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_italic_toggle),
+ selection_is_italic && is_same_is_italic);
+
+ if (is_same_is_bold)
+ {
+ gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
+ selection_is_bold);
+ }
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->font_bold_toggle),
+ selection_is_bold && is_same_is_bold);
+
+ if (is_same_align)
+ gl_debug (DEBUG_PROPERTY_BAR, "same align");
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio),
+ (selection_align == PANGO_ALIGN_LEFT) &&
+ is_same_align);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio),
+ (selection_align == PANGO_ALIGN_CENTER) &&
+ is_same_align);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio),
+ (selection_align == PANGO_ALIGN_RIGHT) &&
+ is_same_align);
+}
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
- text_verbs,
- gl_view_can_selection_text (view));
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
- fill_verbs,
- gl_view_can_selection_fill (view));
+static void
+update_fill_color (glView *view,
+ glUIPropertyBar *this)
+{
+ gboolean can, is_first_object;
+ gboolean is_same_fill_color;
+ GList *p;
+ glLabelObject *object;
+ guint selection_fill_color, fill_color;
+ glColorNode *fill_color_node;
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
- line_color_verbs,
- gl_view_can_selection_line_color (view));
+ can = gl_view_can_selection_fill (view);
+ set_fill_items_sensitive (this, can);
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
- line_width_verbs,
- gl_view_can_selection_line_width (view));
+ if (!can)
+ return;
+ is_same_fill_color = TRUE;
+ is_first_object = TRUE;
+ selection_fill_color = 0;
+
+ for (p = view->selected_object_list; p != NULL; p = p->next)
+ {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (!gl_label_object_can_fill (object))
+ continue;
+
+ fill_color_node = gl_label_object_get_fill_color (object);
+ if (fill_color_node->field_flag)
+ {
+ /* If a merge field is set we use the default color for merged color*/
+ fill_color = GL_COLOR_FILL_MERGE_DEFAULT;
+
+ }
+ else
+ {
+ fill_color = fill_color_node->color;
+ }
+ gl_color_node_free (&fill_color_node);
+
+ if (is_first_object)
+ {
+ selection_fill_color = fill_color;
+ }
+ else
+ {
+ if (fill_color != selection_fill_color)
+ {
+ is_same_fill_color = FALSE;
+ }
+ }
+ is_first_object = FALSE;
+ }
+
+ if (is_same_fill_color)
+ {
+ gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color);
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->fill_color_button),
+ selection_fill_color);
+ }
+}
+
+
+static void
+update_line_color (glView *view,
+ glUIPropertyBar *this)
+{
+ gboolean can, is_first_object;
+ gboolean is_same_line_color;
+ GList *p;
+ glLabelObject *object;
+ guint selection_line_color, line_color;
+ glColorNode *line_color_node;
+
+ can = gl_view_can_selection_line_color (view);
+ set_line_color_items_sensitive (this, can);
+
+ if (!can)
+ return;
+
+ is_same_line_color = TRUE;
+ is_first_object = TRUE;
+ selection_line_color = 0;
+
+ for (p = view->selected_object_list; p != NULL; p = p->next)
+ {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (!gl_label_object_can_line_color (object))
+ continue;
+
+ line_color_node = gl_label_object_get_line_color (object);
+ if (line_color_node->field_flag)
+ {
+ /* If a merge field is set we use the default color for merged color*/
+ line_color = GL_COLOR_MERGE_DEFAULT;
+
+ }
+ else
+ {
+ line_color = line_color_node->color;
+ }
+ gl_color_node_free (&line_color_node);
+
+ if (is_first_object)
+ {
+ selection_line_color = line_color;
+ }
+ else
+ {
+ if (line_color != selection_line_color)
+ {
+ is_same_line_color = FALSE;
+ }
+ }
+ is_first_object = FALSE;
+ }
+
+ if (is_same_line_color)
+ {
+ gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color);
+ gl_color_combo_button_set_color (GL_COLOR_COMBO_BUTTON (this->priv->line_color_button),
+ selection_line_color);
+ }
+}
+
+
+static void
+update_line_width (glView *view,
+ glUIPropertyBar *this)
+{
+ gboolean can, is_first_object;
+ gboolean is_same_line_width;
+ GList *p;
+ glLabelObject *object;
+ gdouble selection_line_width, line_width;
+
+ can = gl_view_can_selection_line_width (view);
+ set_line_width_items_sensitive (this, can);
+
+ if (!can)
+ return;
+
+ is_same_line_width = TRUE;
+ is_first_object = TRUE;
+ selection_line_width = 0;
+
+ for (p = view->selected_object_list; p != NULL; p = p->next)
+ {
+
+ object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+ if (!gl_label_object_can_line_width (object))
+ continue;
+
+ line_width = gl_label_object_get_line_width (object);
+
+ if (is_first_object)
+ {
+ selection_line_width = line_width;
+ }
+ else
+ {
+ if (line_width != selection_line_width)
+ {
+ is_same_line_width = FALSE;
+ }
+ }
+ is_first_object = FALSE;
+ }
+
+ if (is_same_line_width)
+ {
+ gl_debug (DEBUG_PROPERTY_BAR, "same line width = %g", selection_line_width);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (this->priv->line_width_spin),
+ selection_line_width);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (this->priv->line_width_spin), "");
+ }
+}
+
+
+static void
+selection_changed_cb (glUIPropertyBar *this)
+{
+ glView *view = this->priv->view;
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+ g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
+
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ if (gl_view_is_selection_empty (view))
+ {
+ /* No selection: make all controls active. */
+ reset_to_default_properties (view, this);
+ set_doc_items_sensitive (this, TRUE);
+ }
+ else
+ {
+ update_text_properties (view, this);
+ update_fill_color (view, this);
+ update_line_color (view, this);
+ update_line_width (view, this);
}
gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Font family entry changed. */
/*--------------------------------------------------------------------------*/
static void
-font_family_changed_cb (GtkEntry *entry,
- glUIPropertyBar *property_bar)
+font_family_changed_cb (GtkComboBox *combo,
+ glUIPropertyBar *this)
{
gchar *font_family;
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
+
gl_debug (DEBUG_PROPERTY_BAR, "START");
- font_family = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- if ( strlen(font_family) ) {
- gl_view_set_selection_font_family (property_bar->view,
+ font_family = gl_font_combo_get_family (GL_FONT_COMBO (combo));
+ if ( strlen(font_family) )
+ {
+ gl_view_set_selection_font_family (this->priv->view,
font_family);
- gl_view_set_default_font_family (property_bar->view,
+ gl_view_set_default_font_family (this->priv->view,
font_family);
}
g_free (font_family);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Font size spin button changed. */
/*--------------------------------------------------------------------------*/
static void
font_size_changed_cb (GtkSpinButton *spin,
- glUIPropertyBar *property_bar)
+ glUIPropertyBar *this)
{
gdouble font_size;
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
+
gl_debug (DEBUG_PROPERTY_BAR, "START");
font_size = gtk_spin_button_get_value (spin);
- gl_view_set_selection_font_size (property_bar->view,
+ gl_view_set_selection_font_size (this->priv->view,
font_size);
- gl_view_set_default_font_size (property_bar->view,
+ gl_view_set_default_font_size (this->priv->view,
font_size);
gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Text color combo changed. */
/*--------------------------------------------------------------------------*/
static void
-text_color_changed_cb (ColorCombo *cc,
- GdkColor *gdk_color,
- gboolean custom,
- gboolean by_user,
+text_color_changed_cb (glColorComboButton *cc,
+ guint color,
gboolean is_default,
- glUIPropertyBar *property_bar)
+ glUIPropertyBar *this)
{
- guint text_color;
-
- g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+ glColorNode *text_color_node;
- gl_debug (DEBUG_PROPERTY_BAR, "START");
-
- text_color = gl_color_from_gdk_color (gdk_color);
+ g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
- gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
- text_color, custom, by_user, is_default);
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
- if (is_default) {
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
- gl_view_set_selection_text_color (property_bar->view,
- gl_prefs->default_text_color);
- gl_view_set_default_text_color (property_bar->view,
+ text_color_node = gl_color_node_new_default ();
+ text_color_node->color = color;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
+ color, is_default);
+
+ if (is_default)
+ {
+ text_color_node->color = gl_prefs->default_text_color;
+ gl_view_set_selection_text_color (this->priv->view,
+ text_color_node);
+ gl_view_set_default_text_color (this->priv->view,
gl_prefs->default_text_color);
-
- } else {
-
- gl_view_set_selection_text_color (property_bar->view,
- text_color);
- gl_view_set_default_text_color (property_bar->view,
- text_color);
-
+ }
+ else
+ {
+ gl_view_set_selection_text_color (this->priv->view,
+ text_color_node);
+ gl_view_set_default_text_color (this->priv->view,
+ text_color_node->color);
}
+ gl_color_node_free (&text_color_node);
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Fill color combo changed. */
/*--------------------------------------------------------------------------*/
static void
-fill_color_changed_cb (ColorCombo *cc,
- GdkColor *gdk_color,
- gboolean custom,
- gboolean by_user,
+fill_color_changed_cb (glColorComboButton *cc,
+ guint color,
gboolean is_default,
- glUIPropertyBar *property_bar)
+ glUIPropertyBar *this)
{
- guint fill_color;
+ glColorNode *fill_color_node;
- g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+ g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
- gl_debug (DEBUG_PROPERTY_BAR, "START");
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
- fill_color = gl_color_from_gdk_color (gdk_color);
-
- gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
- fill_color, custom, by_user, is_default);
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
- if (is_default) {
+ fill_color_node = gl_color_node_new_default ();
- gl_view_set_selection_fill_color (property_bar->view,
- GL_COLOR_NONE);
- gl_view_set_default_fill_color (property_bar->view,
- GL_COLOR_NONE);
+ fill_color_node->color = color;
- } else {
+ gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
+ color, is_default);
- gl_view_set_selection_fill_color (property_bar->view,
- fill_color);
- gl_view_set_default_fill_color (property_bar->view,
- fill_color);
+ if (is_default)
+ {
+ fill_color_node->color = GL_COLOR_NONE;
+ gl_view_set_selection_fill_color (this->priv->view,
+ fill_color_node);
+ gl_view_set_default_fill_color (this->priv->view,
+ fill_color_node->color);
}
-
+ else
+ {
+ gl_view_set_selection_fill_color (this->priv->view,
+ fill_color_node);
+ gl_view_set_default_fill_color (this->priv->view,
+ fill_color_node->color);
+ }
+ gl_color_node_free (&fill_color_node);
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Line color combo changed. */
/*--------------------------------------------------------------------------*/
static void
-line_color_changed_cb (ColorCombo *cc,
- GdkColor *gdk_color,
- gboolean custom,
- gboolean by_user,
+line_color_changed_cb (glColorComboButton *cc,
+ guint color,
gboolean is_default,
- glUIPropertyBar *property_bar)
+ glUIPropertyBar *this)
{
- guint line_color;
+ glColorNode *line_color_node;
- g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
-
- gl_debug (DEBUG_PROPERTY_BAR, "START");
+ g_return_if_fail (this && GL_IS_UI_PROPERTY_BAR (this));
- line_color = gl_color_from_gdk_color (gdk_color);
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
- gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
- line_color, custom, by_user, is_default);
-
- if (is_default) {
-
- gl_view_set_selection_line_color (property_bar->view,
- GL_COLOR_NONE);
- gl_view_set_default_line_color (property_bar->view,
- GL_COLOR_NONE);
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
- } else {
+ line_color_node = gl_color_node_new_default ();
+ line_color_node->color = color;
- gl_view_set_selection_line_color (property_bar->view,
- line_color);
- gl_view_set_default_line_color (property_bar->view,
- line_color);
+ gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Is_default=%d",
+ color, is_default);
+ if (is_default)
+ {
+ line_color_node->color = GL_COLOR_NONE;
+ gl_view_set_selection_line_color (this->priv->view,
+ line_color_node);
+ gl_view_set_default_line_color (this->priv->view,
+ line_color_node->color);
+ }
+ else
+ {
+ gl_view_set_selection_line_color (this->priv->view,
+ line_color_node);
+ gl_view_set_default_line_color (this->priv->view,
+ line_color_node->color);
}
+ gl_color_node_free (&line_color_node);
gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Line width spin button changed. */
/*--------------------------------------------------------------------------*/
static void
line_width_changed_cb (GtkSpinButton *spin,
- glUIPropertyBar *property_bar)
+ glUIPropertyBar *this)
{
gdouble line_width;
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
+
gl_debug (DEBUG_PROPERTY_BAR, "START");
- line_width = gtk_spin_button_get_value (spin);
+ if (this->priv->view)
+ {
+ line_width = gtk_spin_button_get_value (spin);
- gl_view_set_selection_line_width (property_bar->view,
- line_width);
- gl_view_set_default_line_width (property_bar->view,
- line_width);
+ gl_view_set_selection_line_width (this->priv->view,
+ line_width);
+ gl_view_set_default_line_width (this->priv->view,
+ line_width);
+ }
gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
+
/*---------------------------------------------------------------------------*/
-/* PRIVATE. Property bar item toggled callback. */
+/* PRIVATE. Font bold toggled callback. */
/*---------------------------------------------------------------------------*/
static void
-prop_item_toggled_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- glUIPropertyBar *property_bar)
+font_bold_toggled_cb (GtkToggleToolButton *toggle,
+ glUIPropertyBar *this)
{
- gboolean s;
+ gboolean state;
+ PangoWeight weight;
- gl_debug (DEBUG_PROPERTY_BAR, "");
- s = (strcmp (state, "1") == 0);
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
- /*
- * Font properties: Bold & Italic
- */
- if (strcmp (path, "PropFontBold") == 0)
- {
- GnomeFontWeight weight = s ? GNOME_FONT_BOLD : GNOME_FONT_BOOK;
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
- gl_view_set_selection_font_weight (property_bar->view, weight);
- gl_view_set_default_font_weight (property_bar->view, weight);
- return;
- }
+ state = gtk_toggle_tool_button_get_active (toggle);
- if (strcmp (path, "PropFontItalic") == 0)
- {
- gl_view_set_selection_font_italic_flag (property_bar->view, s);
- gl_view_set_default_font_italic_flag (property_bar->view, s);
- return;
- }
+ weight = state ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
+
+ gl_view_set_selection_font_weight (this->priv->view, weight);
+ gl_view_set_default_font_weight (this->priv->view, weight);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Font italic toggled callback. */
+/*---------------------------------------------------------------------------*/
+static void
+font_italic_toggled_cb (GtkToggleToolButton *toggle,
+ glUIPropertyBar *this)
+{
+ gboolean state;
+
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ state = gtk_toggle_tool_button_get_active (toggle);
- /*
- * Text alignment group
- */
- if (s && (strcmp (path, "PropTextAlignLeft") == 0))
+ gl_view_set_selection_font_italic_flag (this->priv->view, state);
+ gl_view_set_default_font_italic_flag (this->priv->view, state);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Text align toggled callback. */
+/*---------------------------------------------------------------------------*/
+static void
+text_align_toggled_cb (GtkToggleToolButton *toggle,
+ glUIPropertyBar *this)
+{
+ if (this->priv->stop_signals) return;
+ this->priv->stop_signals = TRUE;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_left_radio)))
{
- gl_view_set_selection_text_alignment (property_bar->view,
- GTK_JUSTIFY_LEFT);
- gl_view_set_default_text_alignment (property_bar->view,
- GTK_JUSTIFY_LEFT);
-
- /* Adjust state of siblings */
- gl_ui_util_set_verb_state (ui_component,
- "/commands/PropTextAlignCenter",
- FALSE);
- gl_ui_util_set_verb_state (ui_component,
- "/commands/PropTextAlignRight",
- FALSE);
- return;
+ gl_view_set_selection_text_alignment (this->priv->view,
+ PANGO_ALIGN_LEFT);
+ gl_view_set_default_text_alignment (this->priv->view,
+ PANGO_ALIGN_LEFT);
}
- if (s && (strcmp (path, "PropTextAlignCenter") == 0))
+ if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_center_radio)))
{
- gl_view_set_selection_text_alignment (property_bar->view,
- GTK_JUSTIFY_CENTER);
- gl_view_set_default_text_alignment (property_bar->view,
- GTK_JUSTIFY_CENTER);
-
- /* Adjust state of siblings */
- gl_ui_util_set_verb_state (ui_component,
- "/commands/PropTextAlignLeft",
- FALSE);
- gl_ui_util_set_verb_state (ui_component,
- "/commands/PropTextAlignRight",
- FALSE);
- return;
+ gl_view_set_selection_text_alignment (this->priv->view,
+ PANGO_ALIGN_CENTER);
+ gl_view_set_default_text_alignment (this->priv->view,
+ PANGO_ALIGN_CENTER);
}
- if (s && (strcmp (path, "PropTextAlignRight") == 0))
- {
- gl_view_set_selection_text_alignment (property_bar->view,
- GTK_JUSTIFY_RIGHT);
- gl_view_set_default_text_alignment (property_bar->view,
- GTK_JUSTIFY_RIGHT);
-
- /* Adjust state of siblings */
- gl_ui_util_set_verb_state (ui_component,
- "/commands/PropTextAlignLeft",
- FALSE);
- gl_ui_util_set_verb_state (ui_component,
- "/commands/PropTextAlignCenter",
- FALSE);
- return;
+ if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (this->priv->text_align_right_radio)))
+ {
+ gl_view_set_selection_text_alignment (this->priv->view,
+ PANGO_ALIGN_RIGHT);
+ gl_view_set_default_text_alignment (this->priv->view,
+ PANGO_ALIGN_RIGHT);
}
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
+
+ this->priv->stop_signals = FALSE;
}
-/*---------------------------------------------------------------------------------------*/
-/* NULL command handler -- hides bogus "verb not found" errors for toggle toolbar items. */
-/*---------------------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set sensitivity of doc controls. */
+/*---------------------------------------------------------------------------*/
static void
-null_cmd (BonoboUIComponent *ui_component,
- gpointer user_data,
- const gchar *verbname)
+set_doc_items_sensitive (glUIPropertyBar *this,
+ gboolean state)
{
+ gtk_widget_set_sensitive (this->priv->font_family_combo, state);
+ gtk_widget_set_sensitive (this->priv->font_size_spin, state);
+ gtk_widget_set_sensitive (this->priv->font_bold_toggle, state);
+ gtk_widget_set_sensitive (this->priv->font_italic_toggle, state);
+ gtk_widget_set_sensitive (this->priv->text_align_left_radio, state);
+ gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
+ gtk_widget_set_sensitive (this->priv->text_align_right_radio, state);
+ gtk_widget_set_sensitive (this->priv->text_color_button, state);
+ gtk_widget_set_sensitive (this->priv->fill_color_button, state);
+ gtk_widget_set_sensitive (this->priv->line_color_button, state);
+ gtk_widget_set_sensitive (this->priv->line_width_spin, state);
}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set sensitivity of text related controls. */
+/*---------------------------------------------------------------------------*/
+static void
+set_text_items_sensitive (glUIPropertyBar *this,
+ gboolean state)
+{
+ gtk_widget_set_sensitive (this->priv->font_family_combo, state);
+ gtk_widget_set_sensitive (this->priv->font_size_spin, state);
+ gtk_widget_set_sensitive (this->priv->font_bold_toggle, state);
+ gtk_widget_set_sensitive (this->priv->font_italic_toggle, state);
+ gtk_widget_set_sensitive (this->priv->text_align_left_radio, state);
+ gtk_widget_set_sensitive (this->priv->text_align_center_radio, state);
+ gtk_widget_set_sensitive (this->priv->text_align_right_radio, state);
+ gtk_widget_set_sensitive (this->priv->text_color_button, state);
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set sensitivity of fill related controls. */
+/*---------------------------------------------------------------------------*/
+static void
+set_fill_items_sensitive (glUIPropertyBar *this,
+ gboolean state)
+{
+ gtk_widget_set_sensitive (this->priv->fill_color_button, state);
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set sensitivity of line color related controls. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_color_items_sensitive (glUIPropertyBar *this,
+ gboolean state)
+{
+ gtk_widget_set_sensitive (this->priv->line_color_button, state);
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Set sensitivity of line width related controls. */
+/*---------------------------------------------------------------------------*/
+static void
+set_line_width_items_sensitive (glUIPropertyBar *this,
+ gboolean state)
+{
+ gtk_widget_set_sensitive (this->priv->line_width_spin, state);
+}
+
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */