question about gtk_dialog (gtk2)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

question about gtk_dialog (gtk2)

Wojciech Puchar
how to make dialogs appear on center of screen not on left corner. tried
multiple things no results. For normal windows gtk_window_set_position works

for dialog it doesn't

below is example routine to ask a yes/no question from my program.


i've tried
gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);

but it doesn't work


nt pytanie(const char *txt) {
  GtkWidget *dialog,*lab;
  int odpowiedz;
  dialog=gtk_dialog_new_with_buttons(TEXT_QUESTION,NULL,GTK_DIALOG_DESTROY_WITH_PARENT,
  TEXT_TAK,GTK_RESPONSE_ACCEPT,TEXT_NIE,GTK_RESPONSE_NONE,NULL);
  lab=new_label(txt);
  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area
(GTK_DIALOG (dialog))), lab);
  odpowiedz=gtk_dialog_run(GTK_DIALOG(dialog));
  gtk_widget_destroy(dialog);
  return (odpowiedz==GTK_RESPONSE_ACCEPT);
}

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: question about gtk_dialog (gtk2)

Wojciech Puchar
nobody have idea?


On 2018.06.15 13:43, Wojciech Puchar wrote:

> how to make dialogs appear on center of screen not on left corner.
> tried multiple things no results. For normal windows
> gtk_window_set_position works
>
> for dialog it doesn't
>
> below is example routine to ask a yes/no question from my program.
>
>
> i've tried
> gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
>
> but it doesn't work
>
>
> nt pytanie(const char *txt) {
>  GtkWidget *dialog,*lab;
>  int odpowiedz;
>  dialog=gtk_dialog_new_with_buttons(TEXT_QUESTION,NULL,GTK_DIALOG_DESTROY_WITH_PARENT,
>
>  TEXT_TAK,GTK_RESPONSE_ACCEPT,TEXT_NIE,GTK_RESPONSE_NONE,NULL);
>  lab=new_label(txt);
>  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area
> (GTK_DIALOG (dialog))), lab);
>  odpowiedz=gtk_dialog_run(GTK_DIALOG(dialog));
>  gtk_widget_destroy(dialog);
>  return (odpowiedz==GTK_RESPONSE_ACCEPT);
> }
>

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: question about gtk_dialog (gtk2)

Gtk+ - Apps Dev mailing list
Hi,

I am learning about this, but have not totally figured it out. When I
make a new assistant window, it appears in the upper left of the screen.
Not at (0,0) but nearby.

   assistant = gtk_assistant_new();
   gtk_window_set_transient_for(GTK_WINDOW(assistant), transient_parent);
   gtk_window_set_title (GTK_WINDOW (assistant), title.c_str());
   gtk_window_set_modal (GTK_WINDOW (assistant), TRUE);
   //gtk_window_set_position (GTK_WINDOW(assistant),
GTK_WIN_POS_CENTER_ON_PARENT);
   // the above line does not center the assistant
   gtk_window_set_destroy_with_parent(GTK_WINDOW(assistant), TRUE);

But the following kind of window IS centered:

   projectdialog = gtk_dialog_new();
   gtk_window_set_transient_for(GTK_WINDOW(projectdialog),
transient_parent);
   gtk_window_set_title(GTK_WINDOW(projectdialog), _("Project properties"));
   //gtk_window_set_position(GTK_WINDOW(projectdialog),
GTK_WIN_POS_CENTER_ON_PARENT);
   // the above doesn't matter...with or without, the dialog is centered
   gtk_window_set_modal(GTK_WINDOW(projectdialog), TRUE);
   gtk_window_set_type_hint(GTK_WINDOW(projectdialog),
GDK_WINDOW_TYPE_HINT_DIALOG);

I don't understand it. Also, something in the gtk source code indicates
that setting the position of a window centered can cause problems or
doesn't work reliably, since it can "fight" with the window manager's
preferred placement.

Anybody who knows what they are doing with this?


On 6/21/2018 2:00 AM, Wojciech Puchar wrote:

> nobody have idea?
>
>
> On 2018.06.15 13:43, Wojciech Puchar wrote:
>> how to make dialogs appear on center of screen not on left corner.
>> tried multiple things no results. For normal windows
>> gtk_window_set_position works
>>
>> for dialog it doesn't
>>
>> below is example routine to ask a yes/no question from my program.
>>
>>
>> i've tried
>> gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
>>
>> but it doesn't work
>>
>>
>> nt pytanie(const char *txt) {
>>  GtkWidget *dialog,*lab;
>>  int odpowiedz;
>>  dialog=gtk_dialog_new_with_buttons(TEXT_QUESTION,NULL,GTK_DIALOG_DESTROY_WITH_PARENT,
>>
>>  TEXT_TAK,GTK_RESPONSE_ACCEPT,TEXT_NIE,GTK_RESPONSE_NONE,NULL);
>>  lab=new_label(txt);
>>  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area
>> (GTK_DIALOG (dialog))), lab);
>>  odpowiedz=gtk_dialog_run(GTK_DIALOG(dialog));
>>  gtk_widget_destroy(dialog);
>>  return (odpowiedz==GTK_RESPONSE_ACCEPT);
>> }
>>
>
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: question about gtk_dialog (gtk2)

Gtk+ - Apps Dev mailing list
In reply to this post by Wojciech Puchar
You haven't specified which windowing system you're using.

If it's X11, then the position of a window is always the remit of the
window manager; the position set is a hint, which is taken into account by
the window manager itself, alongside the "this is a dialog" hint that
GtkDialog sets.

There's no toolkit-available way to say "set this window to be at the
center of the screen", unless you create a GTK_WINDOW_POPUP and thus ask
the window manager to *not* manage your window.

Ciao,
 Emmanuele.


On Fri, 15 Jun 2018 at 12:44, Wojciech Puchar <[hidden email]>
wrote:

> how to make dialogs appear on center of screen not on left corner. tried
> multiple things no results. For normal windows gtk_window_set_position
> works
>
> for dialog it doesn't
>
> below is example routine to ask a yes/no question from my program.
>
>
> i've tried
> gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
>
> but it doesn't work
>
>
> nt pytanie(const char *txt) {
>   GtkWidget *dialog,*lab;
>   int odpowiedz;
>
> dialog=gtk_dialog_new_with_buttons(TEXT_QUESTION,NULL,GTK_DIALOG_DESTROY_WITH_PARENT,
>   TEXT_TAK,GTK_RESPONSE_ACCEPT,TEXT_NIE,GTK_RESPONSE_NONE,NULL);
>   lab=new_label(txt);
>   gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area
> (GTK_DIALOG (dialog))), lab);
>   odpowiedz=gtk_dialog_run(GTK_DIALOG(dialog));
>   gtk_widget_destroy(dialog);
>   return (odpowiedz==GTK_RESPONSE_ACCEPT);
> }
>
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>


--
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Fwd: question about gtk_dialog (gtk2)

Gtk+ - Apps Dev mailing list
In reply to this post by Wojciech Puchar
---------- Forwarded message ---------
From: Joël Krähemann <[hidden email]>
Date: Thu, Jun 21, 2018 at 1:11 PM
Subject: Re: question about gtk_dialog (gtk2)
To: Wojciech Puchar <[hidden email]>


Hi Wojciech,

What about:

dialog = g_object_new(GTK_TYPE_DIALOG,
                                 "window-position", GTK_WIN_POS_CENTER,
                                 NULL);

bests,
Joël


On Fri, Jun 15, 2018 at 1:43 PM, Wojciech Puchar
<[hidden email]> wrote:

> how to make dialogs appear on center of screen not on left corner. tried
> multiple things no results. For normal windows gtk_window_set_position works
>
> for dialog it doesn't
>
> below is example routine to ask a yes/no question from my program.
>
>
> i've tried
> gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
>
> but it doesn't work
>
>
> nt pytanie(const char *txt) {
>  GtkWidget *dialog,*lab;
>  int odpowiedz;
>
> dialog=gtk_dialog_new_with_buttons(TEXT_QUESTION,NULL,GTK_DIALOG_DESTROY_WITH_PARENT,
>  TEXT_TAK,GTK_RESPONSE_ACCEPT,TEXT_NIE,GTK_RESPONSE_NONE,NULL);
>  lab=new_label(txt);
>  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG
> (dialog))), lab);
>  odpowiedz=gtk_dialog_run(GTK_DIALOG(dialog));
>  gtk_widget_destroy(dialog);
>  return (odpowiedz==GTK_RESPONSE_ACCEPT);
> }
>
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Fwd: question about gtk_dialog (gtk2)

Gtk+ - Apps Dev mailing list
In reply to this post by Wojciech Puchar
---------- Forwarded message ---------
From: Joël Krähemann <[hidden email]>
Date: Thu, Jun 21, 2018 at 1:21 PM
Subject: Re: question about gtk_dialog (gtk2)
To: Wojciech Puchar <[hidden email]>


Hi,

FYI some properties are only valid as constructor.

cheers,
Joël


On Thu, Jun 21, 2018 at 1:11 PM, Joël Krähemann <[hidden email]> wrote:

> Hi Wojciech,
>
> What about:
>
> dialog = g_object_new(GTK_TYPE_DIALOG,
>                                  "window-position", GTK_WIN_POS_CENTER,
>                                  NULL);
>
> bests,
> Joël
>
>
> On Fri, Jun 15, 2018 at 1:43 PM, Wojciech Puchar
> <[hidden email]> wrote:
>> how to make dialogs appear on center of screen not on left corner. tried
>> multiple things no results. For normal windows gtk_window_set_position works
>>
>> for dialog it doesn't
>>
>> below is example routine to ask a yes/no question from my program.
>>
>>
>> i've tried
>> gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
>>
>> but it doesn't work
>>
>>
>> nt pytanie(const char *txt) {
>>  GtkWidget *dialog,*lab;
>>  int odpowiedz;
>>
>> dialog=gtk_dialog_new_with_buttons(TEXT_QUESTION,NULL,GTK_DIALOG_DESTROY_WITH_PARENT,
>>  TEXT_TAK,GTK_RESPONSE_ACCEPT,TEXT_NIE,GTK_RESPONSE_NONE,NULL);
>>  lab=new_label(txt);
>>  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG
>> (dialog))), lab);
>>  odpowiedz=gtk_dialog_run(GTK_DIALOG(dialog));
>>  gtk_widget_destroy(dialog);
>>  return (odpowiedz==GTK_RESPONSE_ACCEPT);
>> }
>>
>> _______________________________________________
>> gtk-app-devel-list mailing list
>> [hidden email]
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Fwd: question about gtk_dialog (gtk2)

Gtk+ - Apps Dev mailing list
In reply to this post by Wojciech Puchar
---------- Forwarded message ---------
From: Joël Krähemann <[hidden email]>
Date: Thu, Jun 21, 2018 at 1:31 PM
Subject: Re: question about gtk_dialog (gtk2)
To: Wojciech Puchar <[hidden email]>


Hi,

Alternatively, you could inherit GTK_TYPE_DIALOG and do your very own
object. During ::map() and ::realize() you are able to modify the
GdkWindow. Just query parent and child elements for their dimensions.

Just implement:

GtkWidget::map()
GtkWidget::realize()
GtkWidget::size-allocate()
GtkWidget::size-request()

Bests,
Joël


On Thu, Jun 21, 2018 at 1:21 PM, Joël Krähemann <[hidden email]> wrote:

> Hi,
>
> FYI some properties are only valid as constructor.
>
> cheers,
> Joël
>
>
> On Thu, Jun 21, 2018 at 1:11 PM, Joël Krähemann <[hidden email]> wrote:
>> Hi Wojciech,
>>
>> What about:
>>
>> dialog = g_object_new(GTK_TYPE_DIALOG,
>>                                  "window-position", GTK_WIN_POS_CENTER,
>>                                  NULL);
>>
>> bests,
>> Joël
>>
>>
>> On Fri, Jun 15, 2018 at 1:43 PM, Wojciech Puchar
>> <[hidden email]> wrote:
>>> how to make dialogs appear on center of screen not on left corner. tried
>>> multiple things no results. For normal windows gtk_window_set_position works
>>>
>>> for dialog it doesn't
>>>
>>> below is example routine to ask a yes/no question from my program.
>>>
>>>
>>> i've tried
>>> gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
>>>
>>> but it doesn't work
>>>
>>>
>>> nt pytanie(const char *txt) {
>>>  GtkWidget *dialog,*lab;
>>>  int odpowiedz;
>>>
>>> dialog=gtk_dialog_new_with_buttons(TEXT_QUESTION,NULL,GTK_DIALOG_DESTROY_WITH_PARENT,
>>>  TEXT_TAK,GTK_RESPONSE_ACCEPT,TEXT_NIE,GTK_RESPONSE_NONE,NULL);
>>>  lab=new_label(txt);
>>>  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG
>>> (dialog))), lab);
>>>  odpowiedz=gtk_dialog_run(GTK_DIALOG(dialog));
>>>  gtk_widget_destroy(dialog);
>>>  return (odpowiedz==GTK_RESPONSE_ACCEPT);
>>> }
>>>
>>> _______________________________________________
>>> gtk-app-devel-list mailing list
>>> [hidden email]
>>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list