]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkprinteroptionwidget.c
Bug 663856 - Make option-foo accelerators use the right symbol
[~andy/gtk] / gtk / gtkprinteroptionwidget.c
index a4e6f0cf433ae185e170e7e229ea5cc5658d76f2..840fb26414693cbbeb3405ac2c30afadb40badbb 100644 (file)
 #include <ctype.h>
 
 #include "gtkintl.h"
-#include "gtkalignment.h"
 #include "gtkcheckbutton.h"
 #include "gtkcelllayout.h"
 #include "gtkcellrenderertext.h"
 #include "gtkcombobox.h"
-#include "gtkcomboboxentry.h"
 #include "gtkfilechooserbutton.h"
 #include "gtkimage.h"
 #include "gtklabel.h"
 #include "gtkliststore.h"
 #include "gtkradiobutton.h"
 #include "gtkstock.h"
-#include "gtktable.h"
+#include "gtkgrid.h"
 #include "gtktogglebutton.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 
 #include "gtkprinteroptionwidget.h"
-#include "gtkalias.h"
 
 #define GTK_PRINTER_OPTION_WIDGET_GET_PRIVATE(o)  \
    (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINTER_OPTION_WIDGET, GtkPrinterOptionWidgetPrivate))
@@ -62,6 +60,7 @@ struct GtkPrinterOptionWidgetPrivate
   GtkWidget *entry;
   GtkWidget *image;
   GtkWidget *label;
+  GtkWidget *info_label;
   GtkWidget *filechooser;
   GtkWidget *box;
 };
@@ -78,7 +77,7 @@ enum {
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE (GtkPrinterOptionWidget, gtk_printer_option_widget, GTK_TYPE_HBOX)
+G_DEFINE_TYPE (GtkPrinterOptionWidget, gtk_printer_option_widget, GTK_TYPE_BOX)
 
 static void gtk_printer_option_widget_set_property (GObject      *object,
                                                    guint         prop_id,
@@ -106,7 +105,7 @@ gtk_printer_option_widget_class_init (GtkPrinterOptionWidgetClass *class)
 
   widget_class->mnemonic_activate = gtk_printer_option_widget_mnemonic_activate;
 
-  g_type_class_add_private (class, sizeof (GtkPrinterOptionWidgetPrivate));  
+  g_type_class_add_private (class, sizeof (GtkPrinterOptionWidgetPrivate));
 
   signals[CHANGED] =
     g_signal_new ("changed",
@@ -288,11 +287,11 @@ static GtkWidget *
 combo_box_entry_new (void)
 {
   GtkWidget *combo_box;
-  combo_box = gtk_combo_box_entry_new ();
+  combo_box = g_object_new (GTK_TYPE_COMBO_BOX, "has-entry", TRUE, NULL);
 
   combo_box_set_model (combo_box);
 
-  gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (combo_box), NAME_COLUMN);
+  gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combo_box), NAME_COLUMN);
 
   return combo_box;
 }
@@ -374,18 +373,11 @@ combo_box_get (GtkWidget *combo)
   gchar *value;
   GtkTreeIter iter;
 
-  if (GTK_IS_COMBO_BOX_ENTRY (combo))
-    {
-      value = gtk_combo_box_get_active_text(GTK_COMBO_BOX (combo));
-    }
-  else
-    {
-      model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
 
-      value = NULL;
-      if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
-         gtk_tree_model_get (model, &iter, VALUE_COLUMN, &value, -1);
-     }
+  value = NULL;
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
+     gtk_tree_model_get (model, &iter, VALUE_COLUMN, &value, -1);
 
   return value;
 }
@@ -433,6 +425,11 @@ deconstruct_widgets (GtkPrinterOptionWidget *widget)
       gtk_widget_destroy (priv->label);
       priv->label = NULL;
     }
+  if (priv->info_label)
+    {
+      gtk_widget_destroy (priv->info_label);
+      priv->info_label = NULL;
+    }
 }
 
 static void
@@ -748,7 +745,7 @@ construct_widgets (GtkPrinterOptionWidget *widget)
 
     case GTK_PRINTER_OPTION_TYPE_ALTERNATIVE:
       group = NULL;
-      priv->box = gtk_hbox_new (FALSE, 12);
+      priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
       gtk_widget_show (priv->box);
       gtk_box_pack_start (GTK_BOX (widget), priv->box, TRUE, TRUE, 0);
       for (i = 0; i < source->num_choices; i++)
@@ -786,9 +783,9 @@ construct_widgets (GtkPrinterOptionWidget *widget)
       {
         GtkWidget *label;
         
-        priv->filechooser = gtk_table_new (2, 2, FALSE);
-        gtk_table_set_row_spacings (GTK_TABLE (priv->filechooser), 6);
-        gtk_table_set_col_spacings (GTK_TABLE (priv->filechooser), 12);
+        priv->filechooser = gtk_grid_new ();
+        gtk_grid_set_row_spacing (GTK_GRID (priv->filechooser), 6);
+        gtk_grid_set_column_spacing (GTK_GRID (priv->filechooser), 12);
 
         /* TODO: make this a gtkfilechooserentry once we move to GTK */
         priv->entry = gtk_entry_new ();
@@ -800,28 +797,20 @@ construct_widgets (GtkPrinterOptionWidget *widget)
                                          gtk_printer_option_get_activates_default (source));
 
         label = gtk_label_new_with_mnemonic (_("_Name:"));
-        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+        gtk_widget_set_halign (label, GTK_ALIGN_START);
+        gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
         gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->entry);
 
-        gtk_table_attach (GTK_TABLE (priv->filechooser), label,
-                          0, 1, 0, 1, GTK_FILL, 0,
-                          0, 0);
-
-        gtk_table_attach (GTK_TABLE (priv->filechooser), priv->entry,
-                          1, 2, 0, 1, GTK_FILL, 0,
-                          0, 0);
+        gtk_grid_attach (GTK_GRID (priv->filechooser), label, 0, 0, 1, 1);
+        gtk_grid_attach (GTK_GRID (priv->filechooser), priv->entry, 1, 0, 1, 1);
 
         label = gtk_label_new_with_mnemonic (_("_Save in folder:"));
-        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+        gtk_widget_set_halign (label, GTK_ALIGN_START);
+        gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
         gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->combo);
 
-        gtk_table_attach (GTK_TABLE (priv->filechooser), label,
-                          0, 1, 1, 2, GTK_FILL, 0,
-                          0, 0);
-
-        gtk_table_attach (GTK_TABLE (priv->filechooser), priv->combo,
-                          1, 2, 1, 2, GTK_FILL, 0,
-                          0, 0);
+        gtk_grid_attach (GTK_GRID (priv->filechooser), label, 0, 1, 1, 1);
+        gtk_grid_attach (GTK_GRID (priv->filechooser), priv->combo, 1, 1, 1, 1);
 
         gtk_widget_show_all (priv->filechooser);
         gtk_box_pack_start (GTK_BOX (widget), priv->filechooser, TRUE, TRUE, 0);
@@ -831,6 +820,20 @@ construct_widgets (GtkPrinterOptionWidget *widget)
         g_signal_connect (priv->combo, "selection-changed", G_CALLBACK (filesave_changed_cb), widget);
       }
       break;
+
+    case GTK_PRINTER_OPTION_TYPE_INFO:
+      priv->info_label = gtk_label_new (NULL);
+      gtk_label_set_selectable (GTK_LABEL (priv->info_label), TRUE);
+      gtk_widget_show (priv->info_label);
+      gtk_box_pack_start (GTK_BOX (widget), priv->info_label, FALSE, TRUE, 0);
+
+      text = g_strdup_printf ("%s:", source->display_text);
+      priv->label = gtk_label_new_with_mnemonic (text);
+      g_free (text);
+      gtk_widget_show (priv->label);
+
+      break;
+
     default:
       break;
     }
@@ -895,6 +898,9 @@ update_widgets (GtkPrinterOptionWidget *widget)
          gtk_entry_set_text (GTK_ENTRY (priv->entry), source->value);
        break;
       }
+    case GTK_PRINTER_OPTION_TYPE_INFO:
+      gtk_label_set_text (GTK_LABEL (priv->info_label), source->value);
+      break;
     default:
       break;
     }
@@ -927,6 +933,3 @@ gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *widget)
   
   return "";
 }
-
-#define __GTK_PRINTER_OPTION_WIDGET_C__
-#include "gtkaliasdef.c"