gui: Simplify value_to_text() parameters.
[pspp-builds.git] / src / ui / gui / customentry.c
index 2d8f9a0e29b8e91ea9f0f4a452625b0861d17d9f..04e738f23b335bca9b413eecb1b8b7a04bff3c2a 100644 (file)
@@ -1,10 +1,9 @@
-/*
-   PSPPIRE --- A Graphical User Interface for PSPP
-   Copyright (C) 2005  Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2005, 2007, 2010, 2011  Free Software Foundation
 
-   This program is free software; you can redistribute it and/or modify
+   This program 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,
    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., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-*/
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 /*
    This widget is a subclass of GtkEntry.  It's an entry widget with a
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
  */
 
+
 /*
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  */
 
 #include <config.h>
-#include <gettext.h>
-#define _(msgid) gettext (msgid)
-
 
-#include <gtk/gtksignal.h>
-#include <gtk/gtkentry.h>
+#include <gtk/gtk.h>
 #include "customentry.h"
 
 
@@ -114,7 +106,7 @@ psppire_custom_entry_get_type (void)
 static void
 psppire_custom_entry_map (GtkWidget *widget)
 {
-  if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_MAPPED (widget))
+  if (gtk_widget_get_realized (widget) && !gtk_widget_get_mapped (widget))
     {
       GTK_WIDGET_CLASS (parent_class)->map (widget);
       gdk_window_show (PSPPIRE_CUSTOM_ENTRY (widget)->panel);
@@ -124,7 +116,7 @@ psppire_custom_entry_map (GtkWidget *widget)
 static void
 psppire_custom_entry_unmap (GtkWidget *widget)
 {
-  if (GTK_WIDGET_MAPPED (widget))
+  if (gtk_widget_get_mapped (widget))
     {
       gdk_window_hide (PSPPIRE_CUSTOM_ENTRY (widget)->panel);
       GTK_WIDGET_CLASS (parent_class)->unmap (widget);
@@ -240,7 +232,7 @@ psppire_custom_entry_redraw (PsppireCustomEntry *custom_entry)
 
   widget = GTK_WIDGET (custom_entry);
 
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     {
       gtk_widget_queue_draw (widget);
 
@@ -261,8 +253,9 @@ psppire_custom_entry_expose (GtkWidget      *widget,
   g_return_val_if_fail (PSPPIRE_IS_CUSTOM_ENTRY (widget), FALSE);
   g_return_val_if_fail (event != NULL, FALSE);
 
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     {
+      gboolean is_editable;
       GtkShadowType shadow_type;
       GdkRectangle rect;
 
@@ -279,14 +272,14 @@ psppire_custom_entry_expose (GtkWidget      *widget,
 
       shadow_type = psppire_custom_entry_get_shadow_type (ce);
 
-      if (shadow_type != GTK_SHADOW_NONE)
-       {
-         gtk_paint_box (widget->style, ce->panel,
-                        GTK_STATE_NORMAL, shadow_type,
-                        NULL, widget, "customentry",
-                        rect.x, rect.y, rect.width, rect.height);
+      g_object_get (widget, "editable", &is_editable, NULL);
+
+      gtk_paint_box (widget->style, ce->panel,
+                    is_editable ? GTK_STATE_NORMAL: GTK_STATE_INSENSITIVE,
+                    shadow_type,
+                    NULL, widget, "customentry",
+                    rect.x, rect.y, rect.width, rect.height);
 
-       }
 
       gdk_window_end_paint (ce->panel);
     }
@@ -334,7 +327,7 @@ psppire_custom_entry_class_init (PsppireCustomEntryClass *klass)
     (widget_class,
      g_param_spec_enum ("shadow_type",
                        "Shadow Type",
-                       _("Style of bevel around the custom entry button"),
+                       "Style of bevel around the custom entry button",
                        GTK_TYPE_SHADOW_TYPE,
                        GTK_SHADOW_ETCHED_IN,
                        G_PARAM_READABLE),
@@ -374,10 +367,13 @@ psppire_custom_entry_button_press (GtkWidget *widget,
 
   if (event->window == ce->panel)
     {
-      if (!GTK_WIDGET_HAS_FOCUS (widget))
+      gboolean is_editable ;
+      if (!gtk_widget_has_focus (widget))
        gtk_widget_grab_focus (widget);
 
-      if ( event->button == 1)
+      g_object_get (ce, "editable", &is_editable, NULL);
+
+      if ( event->button == 1 && is_editable )
        g_signal_emit (widget, custom_entry_signals[CLICKED], 0);
 
     }
@@ -429,7 +425,7 @@ psppire_custom_entry_size_allocate (GtkWidget     *widget,
 
   GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, &entry_allocation);
 
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     {
       gdk_window_move_resize (PSPPIRE_CUSTOM_ENTRY (widget)->panel,
                              panel_allocation.x,