-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
-/**
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * object-editor.c: object properties editor module
+/*
+ * object-editor.c
+ * Copyright (C) 2003-2009 Jim Evins <evins@snaught.com>.
*
- * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
+ * This file is part of gLabels.
*
- * 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 "object-editor.h"
#include <glib/gi18n.h>
-#include <glade/glade-xml.h>
+#include <gtk/gtkbuilder.h>
#include <gtk/gtklabel.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtkcombobox.h>
#include <math.h>
#include "prefs.h"
-#include "mygal/widget-color-combo.h"
+#include "color-combo.h"
#include "color.h"
#include "wdgt-chain-button.h"
#include "wdgt-merge-menu.h"
#include "debug.h"
+
/*===========================================*/
/* Private macros */
/*===========================================*/
+
/*===========================================*/
/* Private data types */
/*===========================================*/
typedef void (*ChangedSignal) (GObject * object, gpointer data);
+
/*===========================================*/
/* Private globals */
/*===========================================*/
gint gl_object_editor_signals[LAST_SIGNAL] = { 0 };
+
/*===========================================*/
/* Local function prototypes */
/*===========================================*/
static void gl_object_editor_finalize (GObject *object);
static void gl_object_notebook_construct_valist (glObjectEditor *editor,
+ glLabel *label,
glObjectEditorOption first_option,
va_list args);
static void prefs_changed_cb (glObjectEditor *editor);
-\f
+static void label_changed_cb (glLabel *label,
+ glObjectEditor *editor);
+
/*****************************************************************************/
/* Boilerplate object stuff. */
/*****************************************************************************/
G_DEFINE_TYPE (glObjectEditor, gl_object_editor, GTK_TYPE_VBOX);
+
static void
gl_object_editor_class_init (glObjectEditorClass *class)
{
gl_debug (DEBUG_EDITOR, "END");
}
+
static void
gl_object_editor_init (glObjectEditor *editor)
{
+ static gchar *object_ids[] = { "editor_vbox",
+ "adjustment1", "adjustment2", "adjustment3",
+ "adjustment4", "adjustment5", "adjustment6",
+ "adjustment7", "adjustment8", "adjustment9",
+ "adjustment10", "adjustment11", "adjustment12",
+ "adjustment13",
+ NULL };
+ GError *error = NULL;
+
gl_debug (DEBUG_EDITOR, "START");
editor->priv = g_new0 (glObjectEditorPrivate, 1);
- editor->priv->gui = glade_xml_new (GLABELS_GLADE_DIR "object-editor.glade",
- "editor_vbox",
- NULL);
+ editor->priv->builder = gtk_builder_new ();
- if (!editor->priv->gui) {
- g_critical ("Could not open object-editor.glade. gLabels may not be installed correctly!");
+ gtk_builder_add_objects_from_file (editor->priv->builder,
+ GLABELS_BUILDER_DIR "object-editor.builder",
+ object_ids,
+ &error);
+ if (error) {
+ g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
+ g_error_free (error);
return;
}
- editor->priv->editor_vbox = glade_xml_get_widget (editor->priv->gui,
- "editor_vbox");
+ gl_util_get_builder_widgets (editor->priv->builder,
+ "editor_vbox", &editor->priv->editor_vbox,
+ "title_image", &editor->priv->title_image,
+ "title_label", &editor->priv->title_label,
+ "notebook", &editor->priv->notebook,
+ NULL);
+
gtk_box_pack_start (GTK_BOX(editor),
editor->priv->editor_vbox,
FALSE, FALSE, 0);
- editor->priv->title_image = glade_xml_get_widget (editor->priv->gui,
- "title_image");
- editor->priv->title_label = glade_xml_get_widget (editor->priv->gui,
- "title_label");
- editor->priv->notebook = glade_xml_get_widget (editor->priv->gui,
- "notebook");
-
gtk_widget_show_all (GTK_WIDGET(editor));
/* Hide all notebook pages to start with. */
gl_debug (DEBUG_EDITOR, "END");
}
+
static void
gl_object_editor_finalize (GObject *object)
{
g_return_if_fail (GL_IS_OBJECT_EDITOR (editor));
g_return_if_fail (editor->priv != NULL);
- g_object_unref (editor->priv->gui);
- g_free (editor->priv);
-
g_signal_handlers_disconnect_by_func (G_OBJECT(gl_prefs),
prefs_changed_cb, editor);
+ g_signal_handlers_disconnect_by_func (G_OBJECT(editor->priv->label),
+ label_changed_cb, editor);
+
+ g_object_unref (editor->priv->builder);
+ g_free (editor->priv);
G_OBJECT_CLASS (gl_object_editor_parent_class)->finalize (object);
gl_debug (DEBUG_EDITOR, "END");
}
+
/*****************************************************************************/
/* NEW object editor. */
/*****************************************************************************/
GtkWidget*
gl_object_editor_new (gchar *image,
- gchar *label,
+ gchar *title,
+ glLabel *label,
glObjectEditorOption first_option, ...)
{
glObjectEditor *editor;
GTK_ICON_SIZE_LARGE_TOOLBAR);
}
- if (label) {
+ if (title) {
gchar *s;
s = g_strdup_printf ("<span weight=\"bold\">%s</span>",
- label);
+ title);
gtk_label_set_text (GTK_LABEL(editor->priv->title_label), s);
g_free (s);
}
- gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK(editor->priv->notebook), TRUE);
-
va_start (args, first_option);
- gl_object_notebook_construct_valist (editor, first_option, args);
+ gl_object_notebook_construct_valist (editor, label, first_option, args);
va_end (args);
- if (editor->priv->gui) {
- g_object_unref (G_OBJECT (editor->priv->gui));
- }
-
gl_debug (DEBUG_EDITOR, "END");
return GTK_WIDGET(editor);
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Construct notebook. */
/*--------------------------------------------------------------------------*/
static void
gl_object_notebook_construct_valist (glObjectEditor *editor,
+ glLabel *label,
glObjectEditorOption first_option,
va_list args)
{
gl_debug (DEBUG_EDITOR, "START");
+ editor->priv->label = label;
+
option = first_option;
for ( option=first_option; option; option=va_arg (args, glObjectEditorOption) ) {
g_signal_connect_swapped (G_OBJECT (gl_prefs), "changed",
G_CALLBACK (prefs_changed_cb),
editor);
+ if (label)
+ {
+ label_changed_cb (label, editor);
+ g_signal_connect (G_OBJECT (label), "size_changed",
+ G_CALLBACK (label_changed_cb),
+ editor);
+ g_signal_connect (G_OBJECT (label), "merge_changed",
+ G_CALLBACK (label_changed_cb),
+ editor);
+ }
gl_debug (DEBUG_EDITOR, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Widget changed callback. Emit our "changed" signal. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_EDITOR, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Widget size changed callback. Emit our "size-changed" signal. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_EDITOR, "END");
}
+
/*****************************************************************************/
/* Set possible key names from merge object. */
/*****************************************************************************/
gl_debug (DEBUG_EDITOR, "END");
}
-/*****************************************************************************/
-/* Construct color combo "Custom widget". */
-/*****************************************************************************/
-GtkWidget *
-gl_object_editor_construct_color_combo (gchar *name,
- gchar *string1,
- gchar *string2,
- gint int1,
- gint int2)
-{
- GtkWidget *color_combo;
- ColorGroup *cg;
- gchar *cg_name;
- guint color;
- GdkColor *gdk_color;
- gchar *no_color;
-
- switch (int1) {
-
- case 3:
- cg_name = "shadow_color_group";
- color = GL_COLOR_SHADOW_DEFAULT;
- no_color = _("Default");
- break;
-
- case 2:
- cg_name = "text_color_group";
- color = gl_prefs->default_text_color;
- no_color = _("Default");
- break;
-
- case 1:
- cg_name = "line_color_group";
- color = gl_prefs->default_line_color;
- no_color = _("No line");
- break;
-
- case 0:
- default:
- cg_name = "fill_color_group";
- color = gl_prefs->default_fill_color;
- no_color = _("No fill");
- break;
-
- }
-
- cg = color_group_fetch (cg_name, NULL);
- gdk_color = gl_color_to_gdk_color (color);
- color_combo = color_combo_new (NULL, no_color, gdk_color, cg);
- g_free (gdk_color);
-
- color_combo_box_set_preview_relief (COLOR_COMBO(color_combo), GTK_RELIEF_NORMAL);
-
- return color_combo;
-}
-
-/*****************************************************************************/
-/* Construct chain button "Custom widget". */
-/*****************************************************************************/
-GtkWidget *
-gl_object_editor_construct_chain_button (gchar *name,
- gchar *string1,
- gchar *string2,
- gint int1,
- gint int2)
-{
- GtkWidget *chain_button;
-
- chain_button = gl_wdgt_chain_button_new (GL_WDGT_CHAIN_RIGHT);
- gl_wdgt_chain_button_set_active (GL_WDGT_CHAIN_BUTTON(chain_button), TRUE);
-
- return chain_button;
-}
/*--------------------------------------------------------------------------*/
/* PRIVATE. Prefs changed callback. Update units related items. */
gl_debug (DEBUG_EDITOR, "END");
}
+
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. label "changed" callback. */
+/*---------------------------------------------------------------------------*/
+static void
+label_changed_cb (glLabel *label,
+ glObjectEditor *editor)
+{
+ gdouble label_width, label_height;
+ glMerge *merge;
+
+ gl_debug (DEBUG_EDITOR, "START");
+
+ gl_label_get_size (label, &label_width, &label_height);
+ gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor),
+ label_width, label_height);
+ gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor),
+ label_width, label_height);
+ gl_object_editor_set_max_lsize (GL_OBJECT_EDITOR (editor),
+ label_width, label_height);
+ gl_object_editor_set_max_shadow_offset (GL_OBJECT_EDITOR (editor),
+ label_width, label_height);
+
+ merge = gl_label_get_merge (label);
+ gl_object_editor_set_key_names (editor, merge);
+
+ gl_debug (DEBUG_EDITOR, "END");
+}
+
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */