[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gEDA-dev: Button ordering
Hi all,
as discussed previously, the button order can be changed on the fly
using a GTK function. See:
http://developer.gnome.org/doc/API/2.0/gtk/GtkSettings.html#GtkSettings--gtk-alternative-button-order
It's a GTK function, so it doesn't depends on GNOME, but it was included
in 2.6 for the first time.
The requisites for getting this working are:
- we must define a default button ordering. For me, the default order
is "cancel, ok", but it depends on the system you are using. As the
automatic button reordering is there since GTK version 2.6, we must
define the button ordering for previous GTK versions. Can we use this
default ordering as well, or use the alternate "ok, cancel" (current
geda button order)?
- after creating a dialog, we call the function above (only if GTK
version >= 2.6), and the button order is changed automatically if the
GTK property "gtk-alternative-button-order" is TRUE.
I'd like to get some feedback to confirm this solution works for
everyone. So I attach one test program (test.c) which can be compiled
typing:
gcc -Wall -g test.c -o test `pkg-config --cflags gtk+-2.0` `pkg-config
--libs gtk+-2.0`
and then executed: ./test
The defined button order are:
Default: Help, Cancel, OK.
Alternate (GTK >= 2.6 only): Ok, Cancel, Help.
I'd like to get some report (specially for non Linux machines) including
the OS, GTK version (can someone test it with GTK version < 2.6?),
window environment (gnome, kde, mac, windows,...), button order
displayed by the test program, and button order of other native programs
(to see if they are the same).
Thanks,
Carlos
El lun, 11-09-2006 a las 10:51 +0100, Peter Clifton escribió:
> On Sun, 2006-09-10 at 22:58 -0400, Ales Hvezda wrote:
> > Hi Carlos,
> >
> > >A while ago, I spent some time looking for an automatic way to do it
> > >(GTK, or whatever), but I found nothing. Now I looked for it again and I
> > >found it:
> > >http://developer.gnome.org/doc/API/2.0/gtk/GtkSettings.html#GtkSettings--gtk-a
> > >lternative-button-order
> > >
> > >so it can be done. I filled bug #1553483.
> >
> > Interesting. I wouldn't be opposed to this, as long as:
> >
> > 1) it doesn't drag in any gconf, registry thingy, or any additional
> > hidden gnome dependancy.
> >
> > and
> >
> > 2) It doesn't create/require yet another config file.
>
> >From example at
> http://developer.gnome.org/doc/API/2.0/gtk/GtkDialog.html#gtk-dialog-set-alternative-button-order
> (Blank lines removed)
>
> "
> cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
> GTK_STOCK_CANCEL,
> GTK_RESPONSE_CANCEL); ok_button
> = gtk_dialog_add_button (GTK_DIALOG (dialog),
> GTK_STOCK_OK,
> GTK_RESPONSE_OK);
> gtk_widget_grab_default (ok_button); help_button =
> gtk_dialog_add_button (GTK_DIALOG (dialog),
> GTK_STOCK_HELP,
> GTK_RESPONSE_HELP);
> gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
> GTK_RESPONSE_OK,
> GTK_RESPONSE_CANCEL,
> GTK_RESPONSE_HELP,
> -1);
>
> Looks like we set the button order in the default "HIG" ordering, and
> then specify an alternate ordering which is used if the
> "gtk-alternative-button-order" property is set.
>
> There is a default GtkSettings object, and presumably, the
> "gtk-alternative-button-order" property is set in that depending on
> what platform the app is running under. (Or parsed from the gtkrc)
>
>
> This doesn't cover all eventualities well in my opinion, as it doesn't
> say which OS you're defining the alterernate ordering for.
>
> Do we assume that all dialogs should eventually be moved to the Gnome
> HIG ordering, with alternate ordering set to be the reverse (current)
> behaviour? We might then get the old behaviour back by simply
> over-writing the "gtk-alternative-button-order" property.
>
>
> Regards
>
> Peter Clifton
>
>
>
>
> _______________________________________________
> geda-dev mailing list
> geda-dev@moria.seul.org
> http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev
#include <gtk/gtk.h>
static void destroy( GtkWidget *widget,
gpointer data )
{
gtk_main_quit ();
}
int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *dialog;
GtkWidget *label;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (destroy), NULL);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (destroy), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
button = gtk_button_new_with_label ("Exit");
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (destroy), NULL);
g_signal_connect_swapped (G_OBJECT (button), "clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (window));
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window);
dialog = gtk_dialog_new_with_buttons ("Button order test dialog",
GTK_WINDOW(window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OK,
GTK_RESPONSE_OK,
NULL);
#if ((GTK_MAJOR_VERSION >= 2) && (GTK_MINOR_VERSION >= 6))
gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
GTK_RESPONSE_HELP);
if (gtk_alternative_dialog_button_order(NULL)) {
label = gtk_label_new ("This is a button order test dialog\nButton order is the alternative one: OK, Cancel");
} else {
label = gtk_label_new ("This is a button order test dialog\nButton order is the usual one: Cancel, OK");
}
#else
label = gtk_label_new ("Your GTK version is older than 2.6.\nThe button order is hand coded and can't be changed.");
#endif
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
label);
gtk_widget_show_all(dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
gtk_main ();
return 0;
}
_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev