]> git.sur5r.net Git - glabels/blobdiff - glabels2/src/object-editor-shadow-page.c
2009-09-06 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / object-editor-shadow-page.c
index 1396d36b34feeefdc763bef8599ed94d4bb815db..86a3bc06d75d3880884b7eed6cd88243d918df1d 100644 (file)
@@ -1,26 +1,23 @@
-/* -*- 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-shadow-page.c
+ *  Copyright (C) 2006-2009  Jim Evins <evins@snaught.com>.
  *
- *  Copyright (C) 2006  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"
@@ -33,7 +30,7 @@
 #include <math.h>
 
 #include "prefs.h"
-#include "mygal/widget-color-combo.h"
+#include "color-combo.h"
 #include "color.h"
 #include "util.h"
 
 
 #include "debug.h"
 
+
 /*===========================================*/
 /* Private macros                            */
 /*===========================================*/
 
+
 /*===========================================*/
 /* Private data types                        */
 /*===========================================*/
 
+
 /*===========================================*/
 /* Private globals                           */
 /*===========================================*/
 
+
 /*===========================================*/
 /* Local function prototypes                 */
 /*===========================================*/
@@ -74,30 +75,26 @@ gl_object_editor_prepare_shadow_page (glObjectEditor *editor)
        gl_debug (DEBUG_EDITOR, "START");
 
        /* Extract widgets from XML tree. */
-       editor->priv->shadow_page_vbox
-               = glade_xml_get_widget (editor->priv->gui, "shadow_page_vbox");
-       editor->priv->shadow_enable_check
-               = glade_xml_get_widget (editor->priv->gui, "shadow_enable_check");
-       editor->priv->shadow_controls_table
-               = glade_xml_get_widget (editor->priv->gui, "shadow_controls_table");
-       editor->priv->shadow_x_spin
-               = glade_xml_get_widget (editor->priv->gui, "shadow_x_spin");
-       editor->priv->shadow_y_spin
-               = glade_xml_get_widget (editor->priv->gui, "shadow_y_spin");
-       editor->priv->shadow_x_units_label
-               = glade_xml_get_widget (editor->priv->gui, "shadow_x_units_label");
-       editor->priv->shadow_y_units_label
-               = glade_xml_get_widget (editor->priv->gui, "shadow_y_units_label");
-       editor->priv->shadow_color_radio
-               = glade_xml_get_widget (editor->priv->gui, "shadow_color_radio");       
-       editor->priv->shadow_key_radio
-               = glade_xml_get_widget (editor->priv->gui, "shadow_key_radio"); 
-       editor->priv->shadow_color_combo
-               = glade_xml_get_widget (editor->priv->gui, "shadow_color_combo");
-       editor->priv->shadow_key_combo
-               = glade_xml_get_widget (editor->priv->gui, "shadow_key_combo"); 
-       editor->priv->shadow_opacity_spin
-               = glade_xml_get_widget (editor->priv->gui, "shadow_opacity_spin");
+        gl_util_get_builder_widgets (editor->priv->builder,
+                                     "shadow_page_vbox",      &editor->priv->shadow_page_vbox,
+                                     "shadow_enable_check",   &editor->priv->shadow_enable_check,
+                                     "shadow_controls_table", &editor->priv->shadow_controls_table,
+                                     "shadow_x_spin",         &editor->priv->shadow_x_spin,
+                                     "shadow_y_spin",         &editor->priv->shadow_y_spin,
+                                     "shadow_x_units_label",  &editor->priv->shadow_x_units_label,
+                                     "shadow_y_units_label",  &editor->priv->shadow_y_units_label,
+                                     "shadow_color_radio",    &editor->priv->shadow_color_radio,
+                                     "shadow_key_radio",      &editor->priv->shadow_key_radio,
+                                     "shadow_color_hbox",     &editor->priv->shadow_color_hbox,
+                                     "shadow_key_combo",      &editor->priv->shadow_key_combo,
+                                     "shadow_opacity_spin",   &editor->priv->shadow_opacity_spin,
+                                     NULL);
+
+       editor->priv->shadow_color_combo = gl_color_combo_new (_("Default"),
+                                                               GL_COLOR_SHADOW_DEFAULT,
+                                                               GL_COLOR_SHADOW_DEFAULT);
+        gtk_container_add (GTK_CONTAINER (editor->priv->shadow_color_hbox),
+                           editor->priv->shadow_color_combo);
 
        gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->shadow_key_combo));
 
@@ -157,6 +154,7 @@ gl_object_editor_prepare_shadow_page (glObjectEditor *editor)
        gl_debug (DEBUG_EDITOR, "END");
 }
 
+
 /*****************************************************************************/
 /* Set shadow parameters.                                                    */
 /*****************************************************************************/
@@ -177,6 +175,7 @@ gl_object_editor_set_shadow_state (glObjectEditor      *editor,
        gl_debug (DEBUG_EDITOR, "END");
 }
 
+
 void
 gl_object_editor_set_shadow_offset (glObjectEditor      *editor,
                                    gdouble              x,
@@ -205,13 +204,12 @@ gl_object_editor_set_shadow_offset (glObjectEditor      *editor,
        gl_debug (DEBUG_EDITOR, "END");
 }
 
+
 void
 gl_object_editor_set_shadow_color (glObjectEditor      *editor,
                                   gboolean             merge_flag,
                                   glColorNode         *color_node)
 {
-       GdkColor *gdk_color;
-
        gl_debug (DEBUG_EDITOR, "START");
 
         editor->priv->stop_signals = TRUE;
@@ -220,14 +218,12 @@ gl_object_editor_set_shadow_color (glObjectEditor      *editor,
 
        if ( color_node->color == GL_COLOR_NONE ) {
 
-               color_combo_set_color_to_default (COLOR_COMBO(editor->priv->shadow_color_combo));
+               gl_color_combo_set_to_default (GL_COLOR_COMBO(editor->priv->shadow_color_combo));
 
        } else {
 
-               gdk_color = gl_color_to_gdk_color (color_node->color);
-               color_combo_set_color (COLOR_COMBO(editor->priv->shadow_color_combo),
-                                          gdk_color);
-               g_free (gdk_color);
+               gl_color_combo_set_color (GL_COLOR_COMBO(editor->priv->shadow_color_combo),
+                                          color_node->color);
 
        }
        
@@ -252,6 +248,7 @@ gl_object_editor_set_shadow_color (glObjectEditor      *editor,
        gl_debug (DEBUG_EDITOR, "END");
 }
 
+
 void
 gl_object_editor_set_shadow_opacity (glObjectEditor      *editor,
                                     gdouble              alpha)
@@ -281,33 +278,39 @@ gl_object_editor_set_max_shadow_offset (glObjectEditor      *editor,
 
        gl_debug (DEBUG_EDITOR, "START");
 
-        editor->priv->stop_signals = TRUE;
+        if (editor->priv->shadow_page_vbox)
+        {
 
-       /* save a copy in internal units */
-       editor->priv->shadow_x_max = x_max;
-       editor->priv->shadow_y_max = y_max;
+                editor->priv->stop_signals = TRUE;
 
-       /* convert internal units to displayed units */
-       gl_debug (DEBUG_EDITOR, "internal x_max,y_max = %g, %g", x_max, y_max);
-       x_max *= editor->priv->units_per_point;
-       y_max *= editor->priv->units_per_point;
-       gl_debug (DEBUG_EDITOR, "display x_max,y_max = %g, %g", x_max, y_max);
+                /* save a copy in internal units */
+                editor->priv->shadow_x_max = x_max;
+                editor->priv->shadow_y_max = y_max;
 
-       /* Set widget values */
-       tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->shadow_x_spin));
-       gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->shadow_x_spin),
-                                  -x_max, x_max);
-       gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->shadow_x_spin), tmp);
-       tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->shadow_y_spin));
-       gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->shadow_y_spin),
-                                  -y_max, y_max);
-       gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->shadow_y_spin), tmp);
+                /* convert internal units to displayed units */
+                gl_debug (DEBUG_EDITOR, "internal x_max,y_max = %g, %g", x_max, y_max);
+                x_max *= editor->priv->units_per_point;
+                y_max *= editor->priv->units_per_point;
+                gl_debug (DEBUG_EDITOR, "display x_max,y_max = %g, %g", x_max, y_max);
 
-        editor->priv->stop_signals = FALSE;
+                /* Set widget values */
+                tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->shadow_x_spin));
+                gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->shadow_x_spin),
+                                           -x_max, x_max);
+                gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->shadow_x_spin), tmp);
+                tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->shadow_y_spin));
+                gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->shadow_y_spin),
+                                           -y_max, y_max);
+                gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->shadow_y_spin), tmp);
+
+                editor->priv->stop_signals = FALSE;
+
+        }
 
        gl_debug (DEBUG_EDITOR, "END");
 }
 
+
 /*****************************************************************************/
 /* Query shadow parameters.                                                  */
 /*****************************************************************************/
@@ -325,6 +328,7 @@ gl_object_editor_get_shadow_state (glObjectEditor      *editor)
        return state;
 }
 
+
 void
 gl_object_editor_get_shadow_offset (glObjectEditor      *editor,
                                    gdouble             *x,
@@ -347,10 +351,11 @@ gl_object_editor_get_shadow_offset (glObjectEditor      *editor,
        gl_debug (DEBUG_EDITOR, "END");
 }
 
+
 glColorNode*
 gl_object_editor_get_shadow_color (glObjectEditor      *editor)
 {
-        GdkColor    *gdk_color;
+        guint        color;
         gboolean     is_default;
        glColorNode *color_node;
  
@@ -362,15 +367,15 @@ gl_object_editor_get_shadow_color (glObjectEditor      *editor)
                color_node->field_flag = TRUE;
                color_node->key = 
                        gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->shadow_key_combo));
-    } else {
+        } else {
                color_node->field_flag = FALSE;
                color_node->key = NULL;
-               gdk_color = color_combo_get_color (COLOR_COMBO(editor->priv->shadow_color_combo),
-                                           &is_default);
+               color = gl_color_combo_get_color (GL_COLOR_COMBO(editor->priv->shadow_color_combo),
+                                                  &is_default);
 
                if (!is_default) {
-               color_node->color = gl_color_from_gdk_color (gdk_color);
-        }
+                        color_node->color = color;
+                }
        }
 
        gl_debug (DEBUG_EDITOR, "END");
@@ -378,6 +383,7 @@ gl_object_editor_get_shadow_color (glObjectEditor      *editor)
        return color_node;
 }
 
+
 gdouble
 gl_object_editor_get_shadow_opacity (glObjectEditor      *editor)
 {
@@ -440,6 +446,7 @@ shadow_prefs_changed_cb (glObjectEditor *editor)
        gl_debug (DEBUG_EDITOR, "END");
 }
 
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  shadow enable check callback.                                  */
 /*--------------------------------------------------------------------------*/
@@ -487,3 +494,14 @@ shadow_color_radio_toggled_cb (glObjectEditor *editor)
  
         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
+ */