Re: State actions and Glade

2018-10-02 Thread Eric Cashon via gtk-app-devel-list
 
Hi Mitko,

The GtkToolbar doesn't implement the GAction interface so you are out of luck 
there. 

You can use gtk_toggle_tool_button_get_active() to get the state of one of the 
GtkRadioToolButton's in the toolbar.

Eric


//gcc -Wall toolbar1.c -o toolbar1 `pkg-config --cflags --libs gtk+-3.0`

#include

static void get_active_radio(GtkWidget *button, GtkToolItem **radios)
  {
    gint i=0;

    for(i=0;i<3;i++)
 {
   if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(radios[i])))
  {
    g_print("radio%i\n", i+1);
  }
 }
  }
int main(int argc, char **argv)
  {
    gtk_init(&argc, &argv);

    GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "Toolbar");
    gtk_window_set_default_size(GTK_WINDOW(window), 300, 100);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); 

    GtkToolItem *radio1=gtk_radio_tool_button_new(NULL);
    gtk_tool_item_set_expand(radio1, TRUE);
    gtk_tool_button_set_label(GTK_TOOL_BUTTON(radio1), "radio1");
    GtkToolItem 
*radio2=gtk_radio_tool_button_new_from_widget(GTK_RADIO_TOOL_BUTTON(radio1));
    gtk_tool_item_set_expand(radio2, TRUE);
    gtk_tool_button_set_label(GTK_TOOL_BUTTON(radio2), "radio2");  
    GtkToolItem 
*radio3=gtk_radio_tool_button_new_from_widget(GTK_RADIO_TOOL_BUTTON(radio1));
    gtk_tool_item_set_expand(radio3, TRUE);
    gtk_tool_button_set_label(GTK_TOOL_BUTTON(radio3), "radio3"); 

    GtkWidget *toolbar=gtk_toolbar_new();
    gtk_widget_set_hexpand(toolbar, TRUE);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), radio1, 0);  
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), radio2, 1); 
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), radio3, 2); 

    GtkWidget *button=gtk_button_new_with_label("Get Active Radio");
    gtk_widget_set_hexpand(button, TRUE);
    gtk_widget_set_vexpand(button, TRUE);
    GtkToolItem *radios[]={radio1, radio2, radio3};
    g_signal_connect(button, "clicked", G_CALLBACK(get_active_radio), radios); 

    GtkWidget *grid1=gtk_grid_new();
    gtk_container_set_border_width(GTK_CONTAINER(grid1), 15);
    gtk_grid_set_row_spacing(GTK_GRID(grid1), 8);
    gtk_grid_attach(GTK_GRID(grid1), toolbar, 0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(grid1), button, 0, 1, 1, 1);

    gtk_container_add(GTK_CONTAINER(window), grid1);
    
    gtk_widget_show_all(window);

    gtk_widget_grab_focus(button);

    gtk_main();

    return 0;  
  }

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: State actions and Glade

2018-10-02 Thread Mitko Haralanov via gtk-app-devel-list
Can someone please help me with some pointer?

Thank you.

On Tue, Sep 18, 2018 at 9:35 AM Mitko Haralanov 
wrote:

> I am trying to write an application using Glade where the tool bar
> contains a set of radio tool buttons. Those radio tool buttons should not
> perform an action when activated but rather just change the associated
> action's state.
>
> For that I've set the 'Action Name' property for the tool buttons in Glade
> as 'win.radio-state(0)' and 'win.radio-state(1)'.
>
> Since the only thing that I am after is the action's state, I don't even
> need a 'chage_state' handler in the action definition. Therefore, the
> GActionEntry for the radio buttons is defined as:
> {"radio-state", NULL, "i", "0", NULL}
>
> However, no matter what I do, the tool radio buttons are never 'sensitive'
> and I can never click on them.
>
> How should I be using state actions with Glade? It seems that I am doing
> things as described by https://wiki.gnome.org/HowDoI/GAction but it still
> does not work.
>
> Thank you for your help.
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Wayland Window Positioning

2018-10-02 Thread Emmanuele Bassi via gtk-app-devel-list
You probably want to ask on gtk-devel-list and gnome-shell-list.

Wayland interfaces need to be implemented by the compositor, and typically
not piecemeal. That KDE interface seems to be a private interface shared
between Plasma and kwin, like the gtk_shell interface is a private
interface between GTK and GNOME Shell; typically what happens is that
toolkit and compositor developers iterate over their requirements and then
propose the addition of functionality to the xdg_shell shared interface.

You could ask the gnome-shell developers to expose a similar functionality
in the gtk_shell interface, and then GTK would be able to consume it; but
that requires coordination between GNOME Shell and GTK releases.

Ciao,
 Emmanuele.

On Tue, 2 Oct 2018 at 11:13, Gerald Nunn via gtk-app-devel-list <
gtk-app-devel-list@gnome.org> wrote:

> With respect to window positioning in Wayland, I was wondering if mutter
> supports a Wayland extension to position windows similar to what
> PlasmaShell does. Keep in mind I'm not very familiar with Wayland, however
> looking at the Wayland protocol definition for PlasmaShell it looks like
> they have this here:
>
>
> https://github.com/KDE/kwayland/blob/master/src/client/protocols/plasma-shell.xml#L170
>
> Looking at the similar file for gtk-shell I don't see anything similar:
>
>
> https://github.com/GNOME/mutter/blob/master/src/wayland/protocol/gtk-shell.xml
>
> I have a lot of people asking me for Wayland support of quake mode in Tilix
> where the terminal emulator sticks at the top or bottom of the screen.
> Without being able to explicitly position the window this isn't possible.
> Someone pointed me to Yuakake which seems to do it by integrating with the
> PlasmaShell Wayland extension from what I can tell.
>
> Thanks,
>
> Gerald
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>


-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How can I change the font of a text field using non-deprecated way?

2018-10-02 Thread Yuri Khan via gtk-app-devel-list
On Sat, Sep 22, 2018 at 3:11 PM Радомир Хаџић via gtk-app-devel-list
 wrote:

> I'm trying to make a small application in C using GTK+3 (the latest
> stable). The application is going to have a text field implemented using
> GtkTextView where a user can write text. I also font a user to be able to
> change font, so I've added a font chooser using GtkFontChooserDialog.
>
> The problem is that I don't know how to actually set the font of a text
> field to the one that a user chose using font chooser. Well, at least not
> using an up-to-date method. I know I can use gtk_widget_override_font(),
> and though it works perfectly, I'd rather not use it since it's deprecated
> function so it's not meant to be used anymore.

The functionality you are describing is present in pretty much every
GTK+3-based text editor, so look at the source of any one of them.

Gedit (as of 3.18.3 as packaged in Ubuntu 16.04) uses
gtk_widget_override_font, and so does Mousepad (as of 0.4.0), and
what’s good for the stock text editors of GNOME and Xfce, is probably
good for you, too.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK3 + gnuplot

2018-10-02 Thread Yuri Khan via gtk-app-devel-list
On Wed, Sep 19, 2018 at 12:19 AM Allin Cottrell  wrote:

> > The question now is: "How to embed a gnuplot graphic in gtk3?
> > Could you say, please, where to find a simple example, just to undestand
> > how it is possible to do that?
>
> Get gnuplot to produce a PNG file, load the PNG into a GdkPixbuf, then
> stick the GdkPixbuf onto a cairo surface.

Do not do that. With high probability, an application using PNG as an
intermediate plot format will get HiDPI wrong and things will look
either blurry or tiny.

Plot to SVG, then render that.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Cancel a Drag & Drop for some specific items in a Gtk.TreeView

2018-10-02 Thread Yuri Khan via gtk-app-devel-list
On Tue, Sep 11, 2018 at 4:27 AM c.buhtz--- via gtk-app-devel-list
 wrote:

> I have a Gtk.TreeView here. Most but not all of the items should be
> able to be dragged & dropped. For example the first item should not be
> able to be dragged & dropped but it should be selectable.
>
> How can I realize this? Maybe I have to use the drag-begin signal and
> stop the drag in there. But I don't know how.

Reading the “GtkTreeView drag-and-drop”[1] page, I get the impression
that you’d need to implement a wrapper around GtkTreeStore, or
possibly a class derived from GtkTreeStore, that also overrides the
row_draggable method so that it returns False for non-draggable rows.
I have not tried implementing it that way in Python.

[1]: https://developer.gnome.org/gtk3/stable/gtk3-GtkTreeView-drag-and-drop.html
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Wayland Window Positioning

2018-10-02 Thread Gerald Nunn via gtk-app-devel-list
With respect to window positioning in Wayland, I was wondering if mutter
supports a Wayland extension to position windows similar to what
PlasmaShell does. Keep in mind I'm not very familiar with Wayland, however
looking at the Wayland protocol definition for PlasmaShell it looks like
they have this here:

https://github.com/KDE/kwayland/blob/master/src/client/protocols/plasma-shell.xml#L170

Looking at the similar file for gtk-shell I don't see anything similar:

https://github.com/GNOME/mutter/blob/master/src/wayland/protocol/gtk-shell.xml

I have a lot of people asking me for Wayland support of quake mode in Tilix
where the terminal emulator sticks at the top or bottom of the screen.
Without being able to explicitly position the window this isn't possible.
Someone pointed me to Yuakake which seems to do it by integrating with the
PlasmaShell Wayland extension from what I can tell.

Thanks,

Gerald
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list