static void gl_ui_property_bar_construct (glUIPropertyBar *property_bar,
BonoboUIComponent *ui_component);
-static void selection_changed_cb (glView *view,
- glUIPropertyBar *property_bar);
+static void selection_changed_cb (glUIPropertyBar *property_bar);
static void font_family_changed_cb (GtkEntry *entry,
glUIPropertyBar *property_bar);
gl_debug (DEBUG_PROPERTY_BAR, "START");
+ property_bar->stop_signals = TRUE;
property_bar->ui_component = ui_component;
/* Font family entry widget */
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_combo_set_value_in_list (GTK_COMBO(wcombo), TRUE, TRUE);
gtk_entry_set_editable (GTK_ENTRY (property_bar->font_family_entry), FALSE);
gtk_widget_set_size_request (wcombo, 200, -1);
gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE);
+ property_bar->stop_signals = FALSE;
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
/****************************************************************************/
-/* Set view associated with property_bar. */
+/* Fill widgets with default values. */
/****************************************************************************/
-void
-gl_ui_property_bar_set_view (glUIPropertyBar *property_bar,
- glView *view)
+static void
+reset_to_default_properties (glView *view,
+ glUIPropertyBar *property_bar)
{
- glLabel *label;
GList *family_names;
gchar *good_font_family;
GdkColor *gdk_color;
- gl_debug (DEBUG_PROPERTY_BAR, "START");
-
- g_return_if_fail (view && GL_IS_VIEW (view));
- 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,
}
}
gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry), good_font_family);
+ g_free (good_font_family);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin),
view->default_font_size);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->line_width_spin),
view->default_line_width);
+}
+
+/****************************************************************************/
+/* Set view associated with property_bar. */
+/****************************************************************************/
+void
+gl_ui_property_bar_set_view (glUIPropertyBar *property_bar,
+ glView *view)
+{
+ glLabel *label;
+
+ gl_debug (DEBUG_PROPERTY_BAR, "START");
+
+ g_return_if_fail (view && GL_IS_VIEW (view));
+ 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)));
- g_signal_connect (G_OBJECT(view), "selection_changed",
- G_CALLBACK(selection_changed_cb), property_bar);
+ reset_to_default_properties (view, property_bar);
+
+ g_signal_connect_swapped (G_OBJECT(view), "selection_changed",
+ G_CALLBACK(selection_changed_cb), property_bar);
+
+ g_signal_connect_swapped (G_OBJECT(view->label), "changed",
+ G_CALLBACK(selection_changed_cb), property_bar);
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
/*---------------------------------------------------------------------------*/
/* PRIVATE. View "selection state changed" callback. */
/*---------------------------------------------------------------------------*/
+
+static void
+update_text_properties (glView *view,
+ glUIPropertyBar *property_bar)
+{
+ 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_justification;
+ GList *p;
+ glLabelObject *object;
+ gchar *selection_font_family, *font_family;
+ gdouble selection_font_size, font_size;
+ guint selection_text_color, text_color;
+ gboolean selection_is_italic, is_italic;
+ gboolean selection_is_bold, is_bold;
+ GtkJustification selection_justification, justification;
+ GdkColor *gdk_color;
+
+ can_text = gl_view_can_selection_text (view);
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ text_verbs,
+ can_text);
+ if (!can_text)
+ return;
+
+ is_same_is_italic =
+ is_same_is_bold =
+ is_same_justification =
+ is_same_text_color =
+ is_same_font_size =
+ is_same_font_family = TRUE;
+ selection_font_family = NULL;
+ selection_font_size = -1;
+ 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 = gl_label_object_get_text_color (object);
+ is_italic = gl_label_object_get_font_italic_flag (object);
+ is_bold = gl_label_object_get_font_weight (object) == GNOME_FONT_BOLD;
+ justification = 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_justification = justification;
+ } 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 (justification != selection_justification)
+ is_same_justification = FALSE;
+ }
+ is_first_object = FALSE;
+ }
+
+ if (is_same_font_family && (selection_font_family != NULL))
+ gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s",
+ selection_font_family);
+ gtk_entry_set_text (GTK_ENTRY (property_bar->font_family_entry),
+ 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 (property_bar->font_size_spin),
+ selection_font_size);
+ } else {
+ gtk_entry_set_text (GTK_ENTRY (property_bar->font_size_spin), "");
+ }
+
+ if (is_same_text_color) {
+ gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color);
+ gdk_color = gl_color_to_gdk_color (selection_text_color);
+ color_combo_set_color (COLOR_COMBO (property_bar->text_color_combo),
+ gdk_color);
+ g_free (gdk_color);
+ }
+
+ if (is_same_is_italic)
+ gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d",
+ selection_is_italic);
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropFontItalic",
+ selection_is_italic && is_same_is_italic);
+
+ if (is_same_is_bold)
+ gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d",
+ selection_is_bold);
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropFontBold",
+ selection_is_bold && is_same_is_bold);
+
+ if (is_same_justification)
+ gl_debug (DEBUG_PROPERTY_BAR, "same justification");
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropTextAlignRight",
+ (selection_justification == GTK_JUSTIFY_RIGHT) &&
+ is_same_justification);
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropTextAlignLeft",
+ (selection_justification == GTK_JUSTIFY_LEFT) &&
+ is_same_justification);
+ gl_ui_util_set_verb_state (property_bar->ui_component,
+ "/commands/PropTextAlignCenter",
+ (selection_justification == GTK_JUSTIFY_CENTER) &&
+ is_same_justification);
+}
+
+static void
+update_fill_color (glView *view,
+ glUIPropertyBar *property_bar)
+{
+ gboolean can, is_first_object;
+ gboolean is_same_fill_color;
+ GList *p;
+ glLabelObject *object;
+ guint selection_fill_color, fill_color;
+ GdkColor *gdk_color;
+
+ can = gl_view_can_selection_fill (view);
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ fill_verbs,
+ can);
+ if (!can)
+ return;
+
+ is_same_fill_color = TRUE;
+ 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_fill (object))
+ continue;
+
+ fill_color = gl_label_object_get_fill_color (object);
+
+ 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);
+ gdk_color = gl_color_to_gdk_color (selection_fill_color);
+ color_combo_set_color (COLOR_COMBO (property_bar->fill_color_combo),
+ gdk_color);
+ g_free (gdk_color);
+ }
+}
+
+static void
+update_line_color (glView *view,
+ glUIPropertyBar *property_bar)
+{
+ gboolean can, is_first_object;
+ gboolean is_same_line_color;
+ GList *p;
+ glLabelObject *object;
+ guint selection_line_color, line_color;
+ GdkColor *gdk_color;
+
+ can = gl_view_can_selection_line_color (view);
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ line_color_verbs,
+ can);
+ if (!can)
+ return;
+
+ is_same_line_color = TRUE;
+ 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_line_color (object))
+ continue;
+
+ line_color = gl_label_object_get_line_color (object);
+
+ 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);
+ gdk_color = gl_color_to_gdk_color (selection_line_color);
+ color_combo_set_color (COLOR_COMBO (property_bar->line_color_combo),
+ gdk_color);
+ g_free (gdk_color);
+ }
+}
+
+static void
+update_line_width (glView *view,
+ glUIPropertyBar *property_bar)
+{
+ 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);
+ gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
+ line_width_verbs,
+ can);
+ if (!can)
+ return;
+
+ is_same_line_width = TRUE;
+ 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_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 (property_bar->line_width_spin),
+ selection_line_width);
+ } else {
+ gtk_entry_set_text (GTK_ENTRY (property_bar->line_width_spin), "");
+ }
+}
+
static void
-selection_changed_cb (glView *view,
- glUIPropertyBar *property_bar)
+selection_changed_cb (glUIPropertyBar *property_bar)
{
+ glView *view = property_bar->view;
+
gl_debug (DEBUG_PROPERTY_BAR, "START");
g_return_if_fail (view && GL_IS_VIEW (view));
g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
+ property_bar->stop_signals = TRUE;
+
if (gl_view_is_selection_empty (view)) {
/* No selection: make all controls active. */
+ reset_to_default_properties (view, property_bar);
gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
doc_verbs, TRUE);
} else {
- 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));
-
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
- line_color_verbs,
- gl_view_can_selection_line_color (view));
-
- gl_ui_util_set_verb_list_sensitive (property_bar->ui_component,
- line_width_verbs,
- gl_view_can_selection_line_width (view));
+ update_text_properties (view, property_bar);
+ update_fill_color (view, property_bar);
+ update_line_color (view, property_bar);
+ update_line_width (view, property_bar);
}
+ property_bar->stop_signals = FALSE;
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
{
gchar *font_family;
+ if (property_bar->stop_signals)
+ return;
+
gl_debug (DEBUG_PROPERTY_BAR, "START");
+ g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
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);
}
g_free (font_family);
+
+ g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
+ gl_debug (DEBUG_PROPERTY_BAR, "END");
}
/*--------------------------------------------------------------------------*/
{
gdouble font_size;
+ if (property_bar->stop_signals)
+ return;
+
gl_debug (DEBUG_PROPERTY_BAR, "START");
+ g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
font_size = gtk_spin_button_get_value (spin);
gl_view_set_selection_font_size (property_bar->view,
gl_view_set_default_font_size (property_bar->view,
font_size);
+ g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
{
guint text_color;
+ if (property_bar->stop_signals)
+ return;
+
g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
gl_debug (DEBUG_PROPERTY_BAR, "START");
+ g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
text_color = gl_color_from_gdk_color (gdk_color);
gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
}
+ g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
{
guint fill_color;
+ if (property_bar->stop_signals)
+ return;
+
g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
gl_debug (DEBUG_PROPERTY_BAR, "START");
+ g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
fill_color = gl_color_from_gdk_color (gdk_color);
gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
}
+ g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
{
guint line_color;
+ if (property_bar->stop_signals)
+ return;
+
g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar));
gl_debug (DEBUG_PROPERTY_BAR, "START");
+ g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
line_color = gl_color_from_gdk_color (gdk_color);
gl_debug (DEBUG_PROPERTY_BAR, "Color=%08x, Custom=%d, By_User=%d, Is_default=%d",
}
+ g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
{
gdouble line_width;
+ if (property_bar->stop_signals)
+ return;
+
gl_debug (DEBUG_PROPERTY_BAR, "START");
+ g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
line_width = gtk_spin_button_get_value (spin);
gl_view_set_selection_line_width (property_bar->view,
gl_view_set_default_line_width (property_bar->view,
line_width);
+ g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
gl_debug (DEBUG_PROPERTY_BAR, "END");
}
{
gboolean s;
+ if (property_bar->stop_signals)
+ return;
+
gl_debug (DEBUG_PROPERTY_BAR, "");
+ g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
s = (strcmp (state, "1") == 0);
/*
gl_view_set_selection_font_weight (property_bar->view, weight);
gl_view_set_default_font_weight (property_bar->view, weight);
- return;
}
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;
}
gl_ui_util_set_verb_state (ui_component,
"/commands/PropTextAlignRight",
FALSE);
- return;
}
if (s && (strcmp (path, "PropTextAlignCenter") == 0))
gl_ui_util_set_verb_state (ui_component,
"/commands/PropTextAlignRight",
FALSE);
- return;
}
if (s && (strcmp (path, "PropTextAlignRight") == 0))
gl_ui_util_set_verb_state (ui_component,
"/commands/PropTextAlignCenter",
FALSE);
- return;
}
+ g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label),
+ selection_changed_cb,
+ property_bar);
+
}
/*---------------------------------------------------------------------------------------*/