forked from AuroraMiddleware/gtk
printeroptionwidget: Stop using radio buttons
Use grouped check buttons instead.
This commit is contained in:
parent
c9eb497989
commit
151b9c71db
@ -32,7 +32,7 @@
|
|||||||
#include "gtkimage.h"
|
#include "gtkimage.h"
|
||||||
#include "gtklabel.h"
|
#include "gtklabel.h"
|
||||||
#include "gtkliststore.h"
|
#include "gtkliststore.h"
|
||||||
#include "gtkradiobutton.h"
|
#include "gtkcheckbutton.h"
|
||||||
#include "gtkgrid.h"
|
#include "gtkgrid.h"
|
||||||
#include "gtktogglebutton.h"
|
#include "gtktogglebutton.h"
|
||||||
#include "gtkorientable.h"
|
#include "gtkorientable.h"
|
||||||
@ -867,7 +867,7 @@ radio_changed_cb (GtkWidget *button,
|
|||||||
{
|
{
|
||||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
||||||
value = g_object_get_data (G_OBJECT (button), "value");
|
value = g_object_get_data (G_OBJECT (button), "value");
|
||||||
if (value)
|
if (value)
|
||||||
@ -876,16 +876,6 @@ radio_changed_cb (GtkWidget *button,
|
|||||||
emit_changed (widget);
|
emit_changed (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
select_maybe (GtkWidget *widget,
|
|
||||||
const char *value)
|
|
||||||
{
|
|
||||||
char *v = g_object_get_data (G_OBJECT (widget), "value");
|
|
||||||
|
|
||||||
if (strcmp (value, v) == 0)
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
alternative_set (GtkWidget *box,
|
alternative_set (GtkWidget *box,
|
||||||
const char *value)
|
const char *value)
|
||||||
@ -895,28 +885,37 @@ alternative_set (GtkWidget *box,
|
|||||||
for (child = gtk_widget_get_first_child (box);
|
for (child = gtk_widget_get_first_child (box);
|
||||||
child != NULL;
|
child != NULL;
|
||||||
child = gtk_widget_get_next_sibling (child))
|
child = gtk_widget_get_next_sibling (child))
|
||||||
select_maybe (child, value);
|
{
|
||||||
|
char *v = g_object_get_data (G_OBJECT (child), "value");
|
||||||
|
|
||||||
|
if (strcmp (value, v) == 0)
|
||||||
|
{
|
||||||
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (child), TRUE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GSList *
|
static void
|
||||||
alternative_append (GtkWidget *box,
|
alternative_append (GtkWidget *box,
|
||||||
const char *label,
|
const char *label,
|
||||||
const char *value,
|
const char *value,
|
||||||
GtkPrinterOptionWidget *widget,
|
GtkPrinterOptionWidget *widget,
|
||||||
GSList *group)
|
GtkWidget **group)
|
||||||
{
|
{
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
|
||||||
button = gtk_radio_button_new_with_label (group, label);
|
button = gtk_check_button_new_with_label (label);
|
||||||
gtk_widget_show (button);
|
if (*group)
|
||||||
|
gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (*group));
|
||||||
|
else
|
||||||
|
*group = button;
|
||||||
|
|
||||||
gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
|
gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
|
||||||
gtk_box_append (GTK_BOX (box), button);
|
gtk_box_append (GTK_BOX (box), button);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (button), "value", (gpointer)value);
|
g_object_set_data (G_OBJECT (button), "value", (gpointer)value);
|
||||||
g_signal_connect (button, "toggled",
|
g_signal_connect (button, "toggled", G_CALLBACK (radio_changed_cb), widget);
|
||||||
G_CALLBACK (radio_changed_cb), widget);
|
|
||||||
|
|
||||||
return gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -926,7 +925,7 @@ construct_widgets (GtkPrinterOptionWidget *widget)
|
|||||||
GtkPrinterOption *source;
|
GtkPrinterOption *source;
|
||||||
char *text;
|
char *text;
|
||||||
int i;
|
int i;
|
||||||
GSList *group;
|
GtkWidget *group;
|
||||||
|
|
||||||
source = priv->source;
|
source = priv->source;
|
||||||
|
|
||||||
@ -1000,14 +999,14 @@ construct_widgets (GtkPrinterOptionWidget *widget)
|
|||||||
gtk_box_append (GTK_BOX (widget), priv->box);
|
gtk_box_append (GTK_BOX (widget), priv->box);
|
||||||
for (i = 0; i < source->num_choices; i++)
|
for (i = 0; i < source->num_choices; i++)
|
||||||
{
|
{
|
||||||
group = alternative_append (priv->box,
|
alternative_append (priv->box,
|
||||||
source->choices_display[i],
|
source->choices_display[i],
|
||||||
source->choices[i],
|
source->choices[i],
|
||||||
widget,
|
widget,
|
||||||
group);
|
&group);
|
||||||
/* for mnemonic activation */
|
/* for mnemonic activation */
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
priv->button = group->data;
|
priv->button = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source->display_text)
|
if (source->display_text)
|
||||||
|
Loading…
Reference in New Issue
Block a user