Re: Editable SpinButton on a TreeView: detect *every* changes
Hi, On Tue, 2016-11-15 at 02:09 +0100, pozzugno wrote: [...] > I have tried to catch "editing_started", "editing_canceled" and > "edited" > signals of CellRenderer. In "editing_started" callback, I retrieve > and > save the row and column of the cell the user is going to edit. I > also > connect a callback to "value_changed" signal of the GtkAdjustment > associated to the GtkCellRendererSpin. Moreover I save the starting > value so I can restore it if the user will cancel the editing. > > When the user clicks on +/- buttons, "value_changed" is called (so I > can > send the request to the remote device). > > With some tricks, I'm able to restore the original value if the user > cancels the editing and to avoid a duplicate request to the remote > device when the user confirm the value changed by +/- buttons > (actually > when the user moves the focus away from the spinbutton, thus > terminated > the editing). > > As you know, I'm very new to Gtk programming, so I'm wondering > wethere > there's a better approach. Without reading your python code, your approach sounds correct. If you want to get notifications (callbacks) for live editing of editable widgets, you need to handle the editing started signal and then handle signals on the editable widget which is created for that edit session. Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Editable SpinButton on a TreeView: detect *every* changes
Il 14/11/2016 18:19, Pozz Pozz ha scritto: I created with success a TreeView based on a ListStore. One column has a SpinButton (actually a GtkCellRendererSpin). Now I want to detect when the user *is* changing the value, i.e. every time he clicks on + or - buttons. If I connect the "edited" signal, my callack will be called only when the spin button is "unfocused". I lost every clicks. I have tried to catch "editing_started", "editing_canceled" and "edited" signals of CellRenderer. In "editing_started" callback, I retrieve and save the row and column of the cell the user is going to edit. I also connect a callback to "value_changed" signal of the GtkAdjustment associated to the GtkCellRendererSpin. Moreover I save the starting value so I can restore it if the user will cancel the editing. When the user clicks on +/- buttons, "value_changed" is called (so I can send the request to the remote device). With some tricks, I'm able to restore the original value if the user cancels the editing and to avoid a duplicate request to the remote device when the user confirm the value changed by +/- buttons (actually when the user moves the focus away from the spinbutton, thus terminated the editing). As you know, I'm very new to Gtk programming, so I'm wondering wethere there's a better approach. Here it is my code in Python: def on_cellspin_table_editing_started(self, renderer, editable, path): print("editing_started") self.index_of_table = int(path) for column_idx, column in zip(range(len(self.tv_calib.get_columns())), self.tv_calib.get_columns()): if column.get_cells()[0] is renderer: self.table_column = column_idx break self.table_adj = editable.get_adjustment() self.start_value = self.liststore[self.index_of_table][self.table_column] self.table_editing = True self.table_adj.connect("value-changed", self.on_adj_value_changed) def on_cellspin_table_edited(self, renderer, path, new_text): print("edited") self.table_editing = False self.table_adj.disconnect_by_func(self.on_adj_value_changed) new_value = int(new_text) if int(self.table_adj.get_value()) != new_value: self.set_value(self.index_of_table, new_value) def on_cellspin_table_editing_canceled(self, renderer): print("editing_canceled") self.table_editing = False self.table_adj.disconnect_by_func(self.on_adj_value_changed) if self.start_value != int(self.table_adj.get_value()): self.set_value(self.index_of_table, self.table_column, self.start_value) def on_adj_value_changed(self, adj): print("value_changed") self.set_value(self.index_of_table, self.table_column, int(adj.get_value())) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Sharing Gtk.Adjustment objects among several Gtk.SpinButton widgets
Hi; On 14 November 2016 at 17:12, Pozz Pozzwrote: >> A GtkAdjustment is a "model", whereas the widgets using the adjustment >> are the "views". So, if you use the same GtkAdjustment instance, all >> widgets will share the same underlying state. This is by design. >> >> If you want to create different widgets with the same adjustment >> parameters but not sharing the same state you will have to create >> different GtkAdjustment instances — plausibly using a factory method. >> > > Thank you for your answer. My doubt was derived from the following > statements [1]: > > "The GtkAdjustment object does not update the value itself. Instead > it is left up to the > owner of the GtkAdjustment to control the value." > > At first, I thought the value (actual state) was managed (and stored) > directly by the widget, without > changing the value of associated adjustment. > From your words, that sentence says the widgets explicitly change the value > of its adjustment, when needed. Yes; in a broader sense, the widget using an adjustment is both the view and the controller of the value. All a widget does is calling gtk_adjustment_set_value() with the value desired by the user — through direct manipulation of the UI element, or programmatically. The adjustment will then notify the widget of the change, and the widget will update itself to reflect it. This allows multiple widgets to store and manipulate the adjustment. The value itself is a property of the GtkAdjustment instance. Ciao, Emmanuele. -- 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
Editable SpinButton on a TreeView: detect *every* changes
I created with success a TreeView based on a ListStore. One column has a SpinButton (actually a GtkCellRendererSpin). Now I want to detect when the user *is* changing the value, i.e. every time he clicks on + or - buttons. If I connect the "edited" signal, my callack will be called only when the spin button is "unfocused". I lost every clicks. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Sharing Gtk.Adjustment objects among several Gtk.SpinButton widgets
2016-11-14 16:39 GMT+01:00 Emmanuele Bassi: > Hi; > > On 14 November 2016 at 15:36, Pozz Pozz wrote: > > Is it possible to have a single Gtk.Adjustment for several Gtk.SpinButton > > widgets? I couldn't understand if the adjustment is only used by > SpinButton > > to know the range (and some additional details, such as the page size), > or > > the adjustment is used also for the value storage place. > > > > I tried to create two SpinButtons and to set a single adjustment, but it > > seems to me changing the value of a SpinButton will change the value of > the > > other SpinButton too. So it seems it isn't possible to share one > adjustment > > among several widgets. > > > > Of course, I'm supponsing the case of several parameters that have > > different values but the same range properties (min, max, page step, ...) > > A GtkAdjustment is a "model", whereas the widgets using the adjustment > are the "views". So, if you use the same GtkAdjustment instance, all > widgets will share the same underlying state. This is by design. > > If you want to create different widgets with the same adjustment > parameters but not sharing the same state you will have to create > different GtkAdjustment instances — plausibly using a factory method. > Thank you for your answer. My doubt was derived from the following statements [1]: "The GtkAdjustment object does not update the value itself. Instead it is left up to the owner of the GtkAdjustment to control the value." At first, I thought the value (actual state) was managed (and stored) directly by the widget, without changing the value of associated adjustment. From your words, that sentence says the widgets explicitly change the value of its adjustment, when needed. [1] https://developer.gnome.org/gtk3/stable/GtkAdjustment.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Sharing Gtk.Adjustment objects among several Gtk.SpinButton widgets
Hi; On 14 November 2016 at 15:36, Pozz Pozzwrote: > Is it possible to have a single Gtk.Adjustment for several Gtk.SpinButton > widgets? I couldn't understand if the adjustment is only used by SpinButton > to know the range (and some additional details, such as the page size), or > the adjustment is used also for the value storage place. > > I tried to create two SpinButtons and to set a single adjustment, but it > seems to me changing the value of a SpinButton will change the value of the > other SpinButton too. So it seems it isn't possible to share one adjustment > among several widgets. > > Of course, I'm supponsing the case of several parameters that have > different values but the same range properties (min, max, page step, ...) A GtkAdjustment is a "model", whereas the widgets using the adjustment are the "views". So, if you use the same GtkAdjustment instance, all widgets will share the same underlying state. This is by design. If you want to create different widgets with the same adjustment parameters but not sharing the same state you will have to create different GtkAdjustment instances — plausibly using a factory method. Ciao, Emmanuele. -- 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
Sharing Gtk.Adjustment objects among several Gtk.SpinButton widgets
Is it possible to have a single Gtk.Adjustment for several Gtk.SpinButton widgets? I couldn't understand if the adjustment is only used by SpinButton to know the range (and some additional details, such as the page size), or the adjustment is used also for the value storage place. I tried to create two SpinButtons and to set a single adjustment, but it seems to me changing the value of a SpinButton will change the value of the other SpinButton too. So it seems it isn't possible to share one adjustment among several widgets. Of course, I'm supponsing the case of several parameters that have different values but the same range properties (min, max, page step, ...) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkEntry placeholder in GTK2
Hi, Le 14/11/2016 à 14:30, Gabriele Greco a écrit : > I know GTK 3.2+ has a nice gtk_entry_set_placeholder_text() method, but I'm > wondering if there is some clever method to do something similar with GTK2, > I've not found anything googling around, but placeholder texts are a so > common interface concept today that I doubt that someone has not yet > "emulated" it in gtk2... I wrote something like that ages ago, you can find it there: https://github.com/b4n/gvg/blob/master/src/gvg-entry.c I haven't touched this for ages though, but IIRC it worked nicely. Hope it helps, Colomban ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkEntry placeholder in GTK2
Hello, I know GTK 3.2+ has a nice gtk_entry_set_placeholder_text() method, but I'm wondering if there is some clever method to do something similar with GTK2, I've not found anything googling around, but placeholder texts are a so common interface concept today that I doubt that someone has not yet "emulated" it in gtk2... If no one has already done it, I think this could work: - initialize the widget with placeholder text - set a user data on the widget telling the text is placeholder - set the color of the foreground text for this text widget to gray - add a focus in event and a on change event on the widget - if focus in and user data == placeholder, erase the text, save it in another user data, remove the custom style from the gtkentry - if on changed and result text empty reload the placeholder text and switch the style - if on changed and previous text was empty clear the placeholder text and switch the style I wonder if this can work... I can also build a subclass string with this behaviour since I need this in a few different places :( -- *Bye,* * Gabry* ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
glade and compiled resources
So, i know i can compile my resources and glade .ui file and load it using builder. However, i have a problem with icons. Let's say a have a following structure: / window.ui pixmaps/ run-iso.png And an button in .ui with icon_name = run-iso Using gtk_icon_theme_add_resource_path i can tell where to look for my custom icon, and it works. But, how do i tell glade where to look for it? interface-local-resource-path doesn't seem to work for themeable icons ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list