Re: SpinButton: how to avoid calling signal handler when set_value()
Op 11/03/2016 om 12:19 AM schreef pozzugno: > Il 02/11/2016 18:55, Nicola Fontana ha scritto: >> Il Wed, 2 Nov 2016 14:40:58 +0100 Pozz Pozz >> scrisse: >> >>> 2016-11-02 11:24 GMT+01:00 Nicola Fontana : >>>> ... >>>> >>>> you don't necessarily need the handler id. In C (I don't use >>>> python) you could write the following: >>>> >>>> void my_set_value(GtkSpinButton *spin_button, gdouble value) >>>> { >>>> g_signal_handlers_block_matched(spin_button, >>>> G_SIGNAL_MATCH_FUNC, >>>> 0, 0, NULL, >>>> callback_to_skip, >>>> NULL); >>>> >>>> /* This will not trigger callback_to_skip */ >>>> gtk_spin_button_set_value(spin_button, value) >>>> >>>> g_signal_handlers_unblock_matched(spin_button, >>>>G_SIGNAL_MATCH_FUNC, >>>>0, 0, NULL, >>>>callback_to_skip, >>>>NULL); >>>> } >>>> >>> I got the idea. I don't know if g_signal_handlers_block_matched() or >>> similar functionality is available in Python. However, remaining in >>> C, your >>> code make the assumption there is a single callback function for all >>> the >>> spinbuttons. This is not true: I have a different handler for each >>> spinbutton, because I have to make different things. >> Sorry but I am a developer, not a mind reader. > Yes, of course :-) Thank you for spending some time for me. > > I thought using a different callback for each SpinButton was the more > typical solution. > >> You can match by data or try to lookup the callback by detail with >> g_signal_handler_find or refactor your code to use a single >> callback. > It seems pyGObject implementation gives only two "handler block" > functions: handler_block(), that needs the handler_id that I don't > have; handler_block_by_func() that needs the callback to block (the > same problem of your solution, because I have different callbacks). > > Is it possible to retrieve the list of connected callbacks of an > object and a signal name ("value-changed")? > >> The fact that you are using different callbacks has a >> foul smell indeed. > Yes? I have to generate and send a different request to the device. > Why do you think it's better to have a single callback? > Of course, I could write one single callback as: > > def callback(self, spinbutton): > if spinbutton is spinSetting1: > self.callback_setting1(spinbutton) > elif spinbutton is spinSetting2: > self.callback_setting2(spinbutton) > ... > > def callback_setting1(self,spinbutton): > # This is the callback of the spinbutton associated to setting1 > parameter > set_setting1(spinbutton.get_value()) > > It seems to me a more complicated way to write different callbacks. > Do you know you can subclass Gtk.SpinButton and override the virtual methods [1] and emit your own custom signal at the time you want it based of some attribute? There are some example on the internets but not much. Ironically the most complete imo is the old pygtk one [2] and gtk3 read the docs is not horrible [3]. And I want to reiterate what Nicola said, create a small example with only 2 or 3 buttons that shows what you are truing to do. It works much easier that way and we do not have to read minds. ~infirit [1] https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/SpinButton.html#virtual-methods [2] http://www.pygtk.org/articles/writing-a-custom-widget-using-pygtk/writing-a-custom-widget-using-pygtk.htm [3] http://python-gtk-3-tutorial.readthedocs.io/en/latest/objects.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: SpinButton: how to avoid calling signal handler when set_value()
Op 11/03/2016 om 10:47 AM schreef pozzugno: > Another situation, similar to mine. You have a dialog window with a > SpinButton showing the volume speaker. When the dialog is shown, the > SpinButton value should be the current volume level. The user could > change the volume speaker by changing the value of the SpinButton, so > a callback for the "value-changed" signal is connected. The callback > calls the OS API to change the volume speaker. > In this scenario (I think it's very common in GUI applications), the > value of the SpinButton can be changed by code (when the dialog is > shown) and by the user (when he wants to change the volume speaker). So you need to keep properties in sync with each other, right? Binding widgets properties is possible even with some conversion, see [1]. As you refuse to give proper example code I'll leave it at this, good luck. ~infirit [1] https://lazka.github.io/pgi-docs/#GObject-2.0/classes/Object.html#GObject.Object.bind_property ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Why GTK+ ignore, that someone want's to create own widget ?!
Op 12/13/2016 om 03:10 PM schreef Ondrej Tuma: > Now, if I want to get these settings from GTK+, I must doing some > breakneck magic, and I'm still don't know, if I'll get it. That are the > obstacles. Instead of complaining what was and is no more explain what you are trying to accomplish and others may have alternative solutions. My guess is that you were using the border colour to paint or set something to that colour. A possible option is to use your own CSS and loading it with a GtkCssProvider [1]. ~infirit [1] https://developer.gnome.org/gtk3/unstable/GtkCssProvider.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Why GTK+ ignore, that someone want's to create own widget ?!
Op 12/13/2016 om 08:03 PM schreef Ondrej Tuma: > You are near. Application is Mind Map Architect. So I get / use system > colors by default to set map background, selected / normal nodes etc. You probably will get what you want with gtk_style_context_get, so something like below: GdkRGBA *color; gtk_style_context_get (GtkStyleContext, GtkStateFlags, "background-color", &color, NULL); gdk_rgba_free (color); ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: pango_scan_string() deprecation
Op 01/05/2017 om 03:39 PM schreef Richard Shann: > I see that pango_scan_string() is deprecated since version 1.38 > but the documentation doesn't indicate what it should be replaced with - > anyone got any ideas? See [1] for the reasoning. Its now deprecated but from the looks of it there is no intention just yet to remove it. And there is no replacement but its fairly simple and self contained so you could just copy [2] it and include it in your own code. ~infirit [1] https://bugzilla.gnome.org/show_bug.cgi?id=682840 [2] https://git.gnome.org/browse/pango/tree/pango/pango-utils.c#n448 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk3 and fork/exec of non-gtk child
Op 01/14/2017 om 06:05 PM schreef Emmanuele Bassi: >> However, I am still curious as to whether the fork/exec/SIGCHLDhandler model >> of my existing X11/Motif app will or will not work with gtk3. This design >> has worked quite well in this particular application for many years and I am >> reluctant to change it unless there is a strong argument that it either (i) >> no longer works as well as it did because of circumstances peculiar to gtk3 >> vs. X11/Motif or (ii) is likely to stop working in the near-to-medium future >> given current gtk3(/4?) development direction. > If you're not calling any GTK/GDK/X11 functionality in the children, > then you don't need to do anything special after forking. This has > been true for years, and will remain true for the foreseeable future. > The only thing you have to worry about are the usual interactions > between forking and system calls like malloc, or threading primitives. There is an example [1] under python that demonstrates why this is a problem quite well. Hope this helps. ~infirit [1] https://jameswestby.net/weblog/tech/14-caution-python-multiprocessing-and-glib-dont-mix.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GNOME Help Method
Op 02/14/2017 om 11:29 PM schreef Sascha Manns: > actually i'm working on a new GNOME-App. > The codebase is already done. Now i would like to implement a small > method, which launches yelp with the installed apps helpfiles. > The app is prepared in Mono with Gtk-Sharp. > Maybe anyone can help me with a C# method for the help system? > Short answer, you launch a help:// uri and have it handled by whatever provides a desktop file for the uri, typically this is yelp. Longer answer, The docs are either in docbook (not recommended these days) or mallard format installed in /yourappname [1]. Then have your app launch the uri relative to the docdir [2]. If you want to integrate this with your autotools build system see [3]. Several tools are available to help you create and edit the pages [4]. ~infirit [1] this is typically /usr/share/doc [2] example uri help://yourappname [3] https://wiki.gnome.org/Apps/Yelp/Tools/yelp.m4 [4] https://wiki.gnome.org/Apps/Yelp/Tools ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GNOME Help Method
Op 02/15/2017 om 12:01 AM schreef infirit: > Op 02/14/2017 om 11:29 PM schreef Sascha Manns: >> actually i'm working on a new GNOME-App. >> The codebase is already done. Now i would like to implement a small >> method, which launches yelp with the installed apps helpfiles. >> The app is prepared in Mono with Gtk-Sharp. >> Maybe anyone can help me with a C# method for the help system? >> > Short answer, you launch a help:// uri and have it handled by whatever > provides a desktop file for the uri, typically this is yelp. > > Longer answer, The docs are either in docbook (not recommended these > days) or mallard format installed in /yourappname [1]. > Then have your app launch the uri relative to the docdir [2]. If you > want to integrate this with your autotools build system see [3]. Several > tools are available to help you create and edit the pages [4]. I need to correct myself, the proper uri these days is help:yourappname. And I may have gotten your question wrong.. To launch the uri just use something like |gtk_show_uri but then the C# equivalent. An example for this can be found in gedit source [5]. ~infirit [5] https://git.gnome.org/browse/gedit/tree/gedit/gedit-app.c#n221 | ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Weather API
Op 02/22/2017 om 07:44 PM schreef Norbert de Jonge: >> gnome-weather [...] I can i use this libraries with C? > I think, in theory, the GWeather Reference Manual... > https://developer.gnome.org/libgweather/stable/ > ...should have information about its C functions in the Functions > sections. But they are empty, e.g.: > https://developer.gnome.org/libgweather/stable/GWeatherLocationEntry.html > Maybe someone needs to run GTK-Doc to create the manual? Yeah gnome documentation sucks. A reasonable C example can be found in gnome-applets [1]. ~infirit [1] https://git.gnome.org/browse/gnome-applets/tree/gweather ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Weather API
Op 02/23/2017 om 12:37 PM schreef Emmanuele Bassi: >> Yeah gnome documentation sucks. > You may want to avoid insulting people that work really hard at > writing the documentation. Why would anyone be insulted with me stating a fact that has been true for over a decade. Also it does not say anything about the work that people have done on it, it says more on how much the api docs suck. Ignoring for the moment proper developer documentation with buildable examples. And lets have a look how much work has been done on the libgweather documentation.. Last commit is for the api docs is almost 2 years ago and looking at how broken they are today it seems nobody from the gnome team cares. Don't you think it is a shame that the python binding api docs for libgweather is better than the official ones? So I have no problem is saying gnome documentation sucks. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Live Thumbnail of Widgets
On 20/05/17 16:27, Gerald Nunn wrote: > I'm looking for some advice on alternative solutions that would fit my > needs. In an ideal solution, the thumbnails would be updated real time > similar to the windows in gnome-shell when you go into overview mode. > However any solution that increases the rendering speed sufficiently to > permit buffered but near real-time updates would be sufficient as well. I never done anything like this so please anyone correct me if I am wrong, but.. Have you though about connecting to the widget's draw signal? With it you get a cairo context which one usually draws on but I can imagine you could just as well create a pixbuf miniature. So, get the surface from the cairo context with cairo_get_target, then use gdk_pixbuf_get_from_surface to create the pixbuf. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkLabel max-width-chars with ellipsize broken?
Hi, I have been trying to use "max-width-chars" with ellipsize on a label that acts as a page label for a notebook with zero success. It appears it is completely ignored as whatever I use, -1 to 200 nothing ever changes how it looks. How it looks is either we only see a single character with ellipses or just ellipses. Am I missing something? is this the correct way to force a certain width on the label? Thx ~infirit from gi.repository import Gtk, Pango class MyWindow(Gtk.Window): def __init__(self, *args, **kwargs): super().__init__(default_width=400, default_height=300, *args, **kwargs) self.connect("delete-event", Gtk.main_quit) self.notebook = Gtk.Notebook() self.add(self.notebook) for n in (1,2,3): # We should see the first 20 then ellipse label_text = "012345678901234567890" page_label = Gtk.Label( label_text, max_width_chars=20, ellipsize=Pango.EllipsizeMode.END, halign=Gtk.Align.CENTER) page_label.set_tooltip_text(label_text) page_content = Gtk.Image.new_from_icon_name("go-home", Gtk.IconSize.DIALOG) self.notebook.insert_page(page_content, page_label, n) window = MyWindow() window.show_all() Gtk.main() ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkLabel max-width-chars with ellipsize broken?
On 10/06/17 19:39, cecas...@aol.com wrote: > Hi infirit, Hi > Give the hexpand a try and see if that works. It works for me on Python3.5 > and GTK3.18 Define works :) Does it limit to what was set as maximum width chars? When resizing does it use the available space to show more or less characters? Nope :( It indeed does expand the label but it expands to the complete width of the notebook (ugly). While this appears to have the effect to fix the problem is really doesn't as max-width-chars is still not properly used. Its behaviour is very inconsistent imo and appears very broken. Thanks for the response though. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GdkPixbuf and click events
Op 08/03/2017 om 12:02 AM schreef Ferdinand Ramirez via gtk-app-devel-list: > I have a program that adds a GdkPixbuf to a GtkTextView. I would like to > right click on the image and capture the mouse click event and execute a > callback function. Is there any way of achieving this using GdkPixbuf? Not directly with a pixbuf but this is what a GtkDrawArea [1] is for. Create a new drawing area and add the event mask you are interested in (GDK_BUTTON_PRESS_MASK for example) with gtk_widget_add_events. Finally connect to the signal corresponding to the event (following earlier example button-press-event) and do what you want in a callback function. Note that you have to handle drawing yourself which the docs provide an example of. ~infirit [1] https://developer.gnome.org/gtk3/stable/GtkDrawingArea.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Scrolling a GtkTreeview cell
Op 01/22/2018 om 12:03 PM schreef Kian Karas: > I have a GtkTreeview with size constraints, which causes the text of one > particular column in one particular row not to fit into its cell. If I remember correctly a GtkTreeView is scrollable so it will add scrollbars when it has grown larger than its parent widget/window. > Is there a way for the user to scroll the content of a specific cell (i.e. > a specific column in the current highlighted row) - e.g. with the keyboard > arrow keys, when the GtkTreeview has focus? If I understand correctly you force the TreeView to be a specific size. I would try to drop that limitation and force the size on the parent instead and let the TreeView add scrollbars when needed. ~infirit ps: attachments are not allowed ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Accelerators for GtkNotebook to switch between pages
Op 02/02/2018 om 10:33 PM schreef Alexander Koeppe: > I'm looking for a way to switch between the pages of a GtkNotebook using > e.g. Left and Right. What have you tried so far, do you have a basic example, what part did you get stuck on? > I searched the documentation from different angels but didn't found a > obvious way how to accomplish that. I don't think adding accelerators to the labels is an option. Notebook pages are indexed from 0 and you can retrieve the index with gtk_notebook_get_current_page. Then de/increment with 1 and use gtk_notebook_set_current_page. Read up on [1] for the details on getting/settings notebook pages. ~infirit [1] https://developer.gnome.org/gtk3/stable/GtkNotebook.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkRevealer glitches the text view drawing
Op 04-05-18 om 14:55 schreef psp...@mail.bg: > Right now, what I can do is come up with a way to avoid this. I have seen strange things with the GtkInfoBar as well. After hiding and showing it ended up with a negative size which the rest of my app didn't like very much. I worked around it by queuing a resize which is worth a try. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: PyGObject: Which types accepted in a Gtk.ListStore
Op 09-05-18 om 23:50 schreef c.bu...@posteo.jp: > From the api-reference here > <https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/ListStore.html#Gtk.ListStore> > > it is unclear for me what types are accepted for the columns. > The parameter "*column_types" is not explained. > Quoting from the link. >The |Gtk.ListStore| <https://lazka.github.io/pgi-docs/Gtk-3.0/classes/ListStore.html#Gtk.ListStore> can accept most |GObject.Object| <https://lazka.github.io/pgi-docs/GObject-2.0/classes/Object.html#GObject.Object> types as a column type, though it can’t accept all custom types However, if I remember correctly, in the bindings several native python types like int, float and str are mapped to GObject types automatically. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: PyGObject: cell_data_func or own Renderer for date column?
Op 10-05-18 om 00:06 schreef c.bu...@posteo.jp: > I want to have a date column in a Gtk.ListView. The field in the model > is a real "datetime.date". Based on that the content of the column > could display this: > > "2018-05-07" > "2 days ago" > "this week" > "7th May" > "7. Mai '18" Store this string in the Gtk.List/TreeStore, keep the datetime.date somewhere and update the string when the user changes the date format. I never used it but you may want to experiment with storing a GLib.Date object. > This is all based on the same "datetime.date" instance. The user decide > how to display. So I need maximum flexibility. > > A cell_data_function is an option here to implement this. Is it a good > choice? You can of-course do all sorts of things and manipulate to your hearts content but I think you are making it too complicated. You could have two strings, one for the display and another that stores a version that is easily parsed by the datetime module. > What is about deriving from Gtk.CellRendererText? > But I don't see how to do this. May I only overload the render() > function? But how can I read from datetime.date object and convert it > to a string? You subclass and override the virtual methods [1] with your own. For example something like below. class MyRenderer(Gtk.CellRendereText): def __init__(self, datetime): super().__init__() self._datetime = datetime do_render(self, cr, widget, bg_area, cell_area, flags): # implement your own rendering here ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Using SVG for icons (and scaling)
Op 18-07-18 om 02:32 schreef Benjamin Summerton via gtk-app-devel-list: > How do I use an SVG as an Icon where I can scale it based on the DPI? As Luca suggested the easiest is to use an icon name and it will handle it for you. There is possibly another option by using cairo surfaces which I had to use because I had to render something over the icon. I have not used it with svg image so the below pseudo code may not work for you. svg = rsvg_handle_new_from_file(fname, error) surface = gdk_window_create_similar_surface(gdkwin, cairo_content, width, heigth) ctx = cairo_create(surface) rsvg_handle_render_cairo(svg, ctx) image = gtk_image_new_from_surface(surface) You may need to handle scale changes by listening to changes of the scale-factor property on the GtkWidget. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Appending to treestore - how to set selection on new entry?
Op 27-08-18 om 08:24 schreef David C. Rankin: > When I add a new file (entry) to the treestore/treemodel, how do I adjust > the selection so that the new entry is selected? (or how do I get a treepath > or iter from the new entry to allow me to set the selection?) The treestore > holds the name of the entry in the 1st col and then a pointer to a struct > containing details for that textbuffer (e.g. line, col, full path, filemode, > uid/gid, textview and sourceview lang_id along with comment syntax, etc..) > (1) when I append the entry to the tree, e.g. > > GtkTreeStore *treestore; > GtkTreeIter toplevel; toplevel is the treeiter you use to set the selection. > ... > treestore = GTK_TREE_STORE(gtk_tree_view_get_model ( > GTK_TREE_VIEW(app->treeview))); > /* (validate omitted) */ > > /* appeand name and pointer to inst as entry in treeview */ > gtk_tree_store_append (treestore, &toplevel, NULL); > gtk_tree_store_set (treestore, &toplevel, COLNAME, name, -1); > gtk_tree_store_set (treestore, &toplevel, COLINST, inst, -1); > > (here I know the 'inst' which is the pointer stored in column 2) Next is to get the selection from your view with gtk_tree_view_get_selection and call gtk_tree_selection_select_iter with the toplevel iter from earlier. It should now have selected the newly added row. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Own drag icon with same color and font settings as the default drag icon in a Gtk.TreeView
Op 15-09-18 om 00:24 schreef c.buhtz--- via gtk-app-devel-list: > I want the same (background-color, font-face, font-size, font-color) > but with a shorter string (only the second of three columns). You use the Gtk.render_* range of functions. There is one for for every type of content you will want to render onto a cairo surface. If you want to render text put it in a Pango.Layout and use Gtk.render_layout(). ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Own drag icon with same color and font settings as the default drag icon in a Gtk.TreeView
Op 15-09-18 om 14:13 schreef infirit: > You use the Gtk.render_* range of functions. There is one for for every > type of content you will want to render onto a cairo surface. > > If you want to render text put it in a Pango.Layout and use > Gtk.render_layout(). Below is a modified version based of your stackoverflow example. ~infirit #!/usr/bin/env python3 import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk import cairo class MainWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="TreeView Drag and Drop") self.connect("delete-event", Gtk.main_quit) self.box = Gtk.Box() self.add(self.box) # "model" with dummy data self.store = Gtk.TreeStore(int, str, int) for i in range(5): self.store.append(None, [i, 'Item {}'.format(i), i]) # treeview self.tree = Gtk.TreeView(model=self.store) self.box.pack_start(self.tree, True, True, 0) # build columns colA = Gtk.TreeViewColumn('Col A', Gtk.CellRendererText(), text=0) self.tree.append_column(colA) colB = Gtk.TreeViewColumn('Col B', Gtk.CellRendererText(), text=1) self.tree.append_column(colB) colC = Gtk.TreeViewColumn('Col C', Gtk.CellRendererText(), text=2) self.tree.append_column(colC) # enable default drag and drop self.tree.set_reorderable(True) # DnD events self.tree.connect_after("drag-begin", self.drag_begin) def drag_begin(self, widget, context): model, path = widget.get_selection().get_selected_rows() text = model[path][1] stylecontext = widget.get_style_context() # new pango layout pl = widget.create_pango_layout(text) ink_rect, log_rect = pl.get_pixel_extents() padding = 10 # creal surface/context surface = cairo.ImageSurface(cairo.Format.RGB24, log_rect.width + 2 * padding, log_rect.height + 2 * padding) cr = cairo.Context(surface) Gtk.render_background(stylecontext, cr, 0, 0, log_rect.width + 2 * padding, log_rect.height + 2 * padding) Gtk.render_layout(stylecontext, cr, 10, 10, pl) Gtk.drag_set_icon_surface(context, surface) win = MainWindow() win.show_all() Gtk.main() ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: PyGObject: ask for system/theme colors
Op 14-09-18 om 23:19 schreef c.buhtz--- via gtk-app-devel-list: > I don't want to use colors defined by myself e.g. with RGB-values. > I want to use colors from the system (Windows, Linux, ...) and/or the > theme. > > For example I need the background color of a highlighted menu or list > item. > > Is there a way? There is but it is pretty much impossible to do the correct thing with them. See my reply on your other question about the drag icon what you should use. If you want to explore what you do is get a Gtk.StyleContext from a Gtk.Widget with Gtk.Widget.get_style_context(). It hold the information you are looking for like font and colour information. You retrieve them with Gtk.StyleContext.get_property() with a Gtk.STYLE_PROPERTY_* property and Gtk.StateFlags.*. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Working with embedded images with GResource, GdkPixbuf and GtkWidget
Op 11-11-18 om 18:23 schreef Alessandro Francesconi: I can’t really understand how Pixbuf expects from the GResource data… also i read in the docs that “gdk_pixbuf_new_from_inline has been deprecated since version 2.32 and should not be used in newly-written code. Use GResource instead.”… so what’s the correct way to create Pixbuf for About boxes and GdkWidgets for image button? Never used GResource but.. The GdkPixbuf docs has gdk_pixbuf_new_from_resource() which will take the path to the pixdata in the GResource. The path based on your example probably is /myapp/icons/logo.png. ~infirit ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list