mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 00:30:08 +00:00
fix printer options
This commit is contained in:
parent
4d71199012
commit
3f84abf926
@ -1,3 +1,9 @@
|
||||
2006-08-23 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkprinteroptionwidget.[hc]: Fix confusion about
|
||||
names and values in comboboxes, and clean up some
|
||||
coding style issues.
|
||||
|
||||
2006-08-23 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* gtk/gtkfilesystemwin32.c (gtk_file_system_win32_make_path):
|
||||
|
@ -256,12 +256,18 @@ gtk_printer_option_widget_set_source (GtkPrinterOptionWidget *widget,
|
||||
g_object_notify (G_OBJECT (widget), "source");
|
||||
}
|
||||
|
||||
enum {
|
||||
NAME_COLUMN,
|
||||
VALUE_COLUMN,
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
static void
|
||||
combo_box_set_model (GtkWidget *combo_box)
|
||||
{
|
||||
GtkListStore *store;
|
||||
|
||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
|
||||
store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
|
||||
g_object_unref (store);
|
||||
}
|
||||
@ -274,7 +280,7 @@ combo_box_set_view (GtkWidget *combo_box)
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
|
||||
"text", 1,
|
||||
"text", NAME_COLUMN,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@ -286,7 +292,7 @@ combo_box_entry_new (void)
|
||||
|
||||
combo_box_set_model (combo_box);
|
||||
|
||||
gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (combo_box), 1);
|
||||
gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (combo_box), NAME_COLUMN);
|
||||
|
||||
return combo_box;
|
||||
}
|
||||
@ -305,8 +311,8 @@ combo_box_new (void)
|
||||
|
||||
static void
|
||||
combo_box_append (GtkWidget *combo,
|
||||
const char *display_text,
|
||||
const char *value)
|
||||
const gchar *display_text,
|
||||
const gchar *value)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
@ -317,24 +323,27 @@ combo_box_append (GtkWidget *combo,
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
0, display_text,
|
||||
1, value,
|
||||
NAME_COLUMN, display_text,
|
||||
VALUE_COLUMN, value,
|
||||
-1);
|
||||
}
|
||||
|
||||
struct ComboSet {
|
||||
GtkComboBox *combo;
|
||||
const char *value;
|
||||
const gchar *value;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
set_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||
set_cb (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
struct ComboSet *set_data = data;
|
||||
gboolean found;
|
||||
char *value;
|
||||
|
||||
gtk_tree_model_get (model, iter, 1, &value, -1);
|
||||
gtk_tree_model_get (model, iter, VALUE_COLUMN, &value, -1);
|
||||
found = (strcmp (value, set_data->value) == 0);
|
||||
g_free (value);
|
||||
|
||||
@ -346,7 +355,7 @@ set_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data
|
||||
|
||||
static void
|
||||
combo_box_set (GtkWidget *combo,
|
||||
const char *value)
|
||||
const gchar *value)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
@ -364,24 +373,23 @@ static char *
|
||||
combo_box_get (GtkWidget *combo)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
char *val;
|
||||
gchar *value;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (GTK_IS_COMBO_BOX_ENTRY (combo))
|
||||
{
|
||||
val = gtk_combo_box_get_active_text(GTK_COMBO_BOX (combo));
|
||||
value = gtk_combo_box_get_active_text(GTK_COMBO_BOX (combo));
|
||||
}
|
||||
else
|
||||
{
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
|
||||
|
||||
val = NULL;
|
||||
value = NULL;
|
||||
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
|
||||
gtk_tree_model_get (model, &iter,
|
||||
1, &val,
|
||||
-1);
|
||||
gtk_tree_model_get (model, &iter, VALUE_COLUMN, &value, -1);
|
||||
}
|
||||
return val;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@ -443,7 +451,7 @@ check_toggled_cb (GtkToggleButton *toggle_button,
|
||||
}
|
||||
|
||||
static void
|
||||
filesave_changed_cb (GtkWidget *w,
|
||||
filesave_changed_cb (GtkWidget *button,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||
@ -487,8 +495,8 @@ filesave_changed_cb (GtkWidget *w,
|
||||
emit_changed (widget);
|
||||
}
|
||||
|
||||
static char *
|
||||
filter_numeric (const char *val,
|
||||
static gchar *
|
||||
filter_numeric (const gchar *val,
|
||||
gboolean allow_neg,
|
||||
gboolean allow_dec,
|
||||
gboolean *changed_out)
|
||||
@ -530,6 +538,7 @@ filter_numeric (const char *val,
|
||||
|
||||
return filtered_val;
|
||||
}
|
||||
|
||||
static void
|
||||
combo_changed_cb (GtkWidget *combo,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
@ -586,7 +595,7 @@ entry_changed_cb (GtkWidget *entry,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||
const char *value;
|
||||
const gchar *value;
|
||||
|
||||
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
||||
value = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
@ -602,7 +611,7 @@ radio_changed_cb (GtkWidget *button,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||
char *value;
|
||||
gchar *value;
|
||||
|
||||
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
||||
value = g_object_get_data (G_OBJECT (button), "value");
|
||||
@ -616,7 +625,7 @@ static void
|
||||
select_maybe (GtkWidget *widget,
|
||||
const gchar *value)
|
||||
{
|
||||
char *v = g_object_get_data (G_OBJECT (widget), "value");
|
||||
gchar *v = g_object_get_data (G_OBJECT (widget), "value");
|
||||
|
||||
if (strcmp (value, v) == 0)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
@ -886,7 +895,7 @@ gtk_printer_option_widget_get_external_label (GtkPrinterOptionWidget *widget)
|
||||
return widget->priv->label;
|
||||
}
|
||||
|
||||
const char *
|
||||
const gchar *
|
||||
gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||
|
@ -52,12 +52,12 @@ struct _GtkPrinterOptionWidgetClass
|
||||
|
||||
GType gtk_printer_option_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gtk_printer_option_widget_new (GtkPrinterOption *source);
|
||||
GtkWidget *gtk_printer_option_widget_new (GtkPrinterOption *source);
|
||||
void gtk_printer_option_widget_set_source (GtkPrinterOptionWidget *setting,
|
||||
GtkPrinterOption *source);
|
||||
gboolean gtk_printer_option_widget_has_external_label (GtkPrinterOptionWidget *setting);
|
||||
GtkWidget * gtk_printer_option_widget_get_external_label (GtkPrinterOptionWidget *setting);
|
||||
const char *gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *setting);
|
||||
GtkWidget *gtk_printer_option_widget_get_external_label (GtkPrinterOptionWidget *setting);
|
||||
const gchar *gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user