Re: PyGObject: pep8 konform

2018-06-01 Thread James Cameron
Code that uses PyGObject can't be PEP8 conformant without generating
version warnings.  My practice is to minimise E402 by moving imports,
then add .flake8 file with;

[flake8]

# E402 module level import not at top of file
# gi.require_version() is required before later imports

ignore = E402

-- 
James Cameron
http://quozl.netrek.org/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: This takes 30 secs to render

2018-06-01 Thread Eric Cashon via gtk-app-devel-list


 
The other way to go about it is to just use cairo. I don't think that it will 
give a speed improvement but it might be worth a try. I figure you are trying 
to scale the png first and then draw it in a widget. Once the image is sized it 
shouldn't be a problem to draw quickly.


Eric



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

#include

static gboolean da_drawing(GtkWidget *da, cairo_t *cr, cairo_surface_t 
*surface);
static void save_png();
static cairo_surface_t *get_and_scale_png();

int main(int argc, char *argv[])
  {
gtk_init(, );

GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Big PNG");
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 500, 500);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

GTimer *timer=g_timer_new();
save_png();
g_print("Save Time %f\n", g_timer_elapsed(timer, NULL));
g_timer_start(timer);
cairo_surface_t *surface=get_and_scale_png();
g_print("Get Time %f\n", g_timer_elapsed(timer, NULL));
g_timer_destroy(timer);

GtkWidget *da=gtk_drawing_area_new();
gtk_widget_set_size_request(da, 1, 1);
gtk_widget_set_hexpand(da, TRUE);
gtk_widget_set_vexpand(da, TRUE);
g_signal_connect(da, "draw", G_CALLBACK(da_drawing), surface);

GtkWidget *scroll=gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(scroll), da);
  
GtkWidget *grid=gtk_grid_new();
gtk_grid_attach(GTK_GRID(grid), scroll, 0, 0, 1, 1);
  
gtk_container_add(GTK_CONTAINER(window), grid);
gtk_widget_show_all(window);

gtk_main();

cairo_surface_destroy(surface);

return 0;
  }
static gboolean da_drawing(GtkWidget *da, cairo_t *cr, cairo_surface_t *surface)
  {   
GTimer *timer=g_timer_new(); 
cairo_set_source_surface(cr, surface, 0.0, 0.0);
cairo_paint(cr);
g_print("Draw Time %f\n", g_timer_elapsed(timer, NULL));
g_timer_destroy(timer);

return FALSE;
  }
static void save_png()
  {
gdouble width=5000.0;
gdouble height=5000.0;
cairo_surface_t *surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 
width, height);
cairo_t *cr=cairo_create(surface);
   
//Paint the green background.
cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);
cairo_paint(cr);

cairo_set_source_rgba(cr, 1.0, 0.0, 1.0, 1.0);
cairo_set_line_width(cr, 80.0);
cairo_rectangle(cr, 0.0, 0.0, width, height);
cairo_stroke(cr);

cairo_surface_write_to_png(surface, "big.png");

cairo_destroy(cr);
cairo_surface_destroy(surface);
  }
static cairo_surface_t *get_and_scale_png()
  {
//The 5,000x5,000 surface.
cairo_surface_t *surface=cairo_image_surface_create_from_png("big.png");

//Scale to 1/10 of width and height.
cairo_surface_t *surface2=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 
500.0, 500.0);
cairo_t *cr2=cairo_create(surface2);

cairo_scale(cr2, 1.0/10.0, 1.0/10.0);
cairo_set_source_surface(cr2, surface, 0.0, 0.0);
cairo_pattern_set_filter(cairo_get_source(cr2), CAIRO_FILTER_FAST);
cairo_paint(cr2);

cairo_destroy(cr2);
cairo_surface_destroy(surface);

return surface2;
  }


 


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


Re: Undefined reference to g_file_load_bytes()

2018-06-01 Thread pspgen



- Цитат от Emmanuele Bassi (eba...@gmail.com), на 01.06.2018
в 11:20 -  Hi;


g_file_load_bytes() is available since GLib 2.56:


 https://developer.gnome.org/gio/stable/GFile.html#g-file-load-bytes


so you'll need to make sure that the version of GLib provided by MSYS2 is
new enough if you want to use that method.


Currently the newest windows port of glib is GLib 2.48, which is the
version of GLib I currently have..




-
Mail.BG: Безплатен e-mail адрес. Най-добрите характеристики на българския пазар 
- 30 GB пощенска кутия, 1 GB прикрепен файл, безплатен POP3, мобилна версия и 
други. http://mail.bg
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: PyGObject: pep8 konform

2018-06-01 Thread Gergely Polonkai
My take would be to ignore this specific line with a magic comment. Or, if
you really donʼt want to d that, a

from importlib import import_module # isnʼt that line wonderful?
Gtk = import_module('gi.repository.Gtk')

might do the trick.

(Note that I wrote it without having Python at hand; maybe you have to
import gi.repository, and do getattr(repository, Gtk) instead.)

Best,
Gergely

On Fri, Jun 1, 2018, 14:47  wrote:

> How do I make PyGObject code PEP8 konform?
>
> e.g.
>
> #!/usr/bin/env python3
> import gi
> gi.require_version('Gtk', '3.0')
> from gi.repository import Gtk
>
> This code causes
> E402 module level import not at top of file
> E402 module level import not at top of file
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Link Gtk.ListStore to the real data

2018-06-01 Thread c . buhtz
I opened a question on StackOverflow about this and created a (not so) 
minimal working example for it there.

https://stackoverflow.com/q/50643938/4865723
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


PyGObject: pep8 konform

2018-06-01 Thread c . buhtz

How do I make PyGObject code PEP8 konform?

e.g.

#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

This code causes
E402 module level import not at top of file
E402 module level import not at top of file
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Undefined reference to g_file_load_bytes()

2018-06-01 Thread Emmanuele Bassi
Hi;

g_file_load_bytes() is available since GLib 2.56:

  https://developer.gnome.org/gio/stable/GFile.html#g-file-load-bytes

so you'll need to make sure that the version of GLib provided by MSYS2 is
new enough if you want to use that method.

Ciao,
 Emmanuele.


On 1 June 2018 at 01:21, PC Buddies  wrote:

>  During my application programming, I had to use the GIO function
> g_file_load_bytes().
>
> I have my GTK+ installation installed from MSYS (the new method)
> so I obviously have GIO. I previously even used g_file_load_contents()
> without problems, but now, it weirdly doesn't find definition for
> `g_file_load_bytes()` in the libraries..
>
> I checked the headers and not surprisingly I could not find declarations
> for this function either. I have had similar problem with other glib
> functions before too, most of the functions from the man page work, but
> some not.
>
> What should I do?
> ___
> 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: guchar * sometimes a utf8, sometimes utf16?

2018-06-01 Thread Emmanuele Bassi
Hi;

this mailing list is not for the GTK port of WebKit; you should ask on:

  https://lists.webkit.org/mailman/listinfo/webkit-gtk

Ciao,
 Emmanuele.

On 31 May 2018 at 23:04, Leo Ufimtsev  wrote:

> Hello guys,
>
> The following method:
> guchar * webkit_web_resource_get_data_finish(..)
>
> Sometimes returns utf8 and sometimes utf16. Is there a way to tell them
> apart?
>
> Thank you.
>
> --
> Leo Ufimtsev, Software Engineer, Red Hat
> ___
> 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


Undefined reference to g_file_load_bytes()

2018-06-01 Thread PC Buddies
 During my application programming, I had to use the GIO function
g_file_load_bytes().

I have my GTK+ installation installed from MSYS (the new method)
so I obviously have GIO. I previously even used g_file_load_contents()
without problems, but now, it weirdly doesn't find definition for
`g_file_load_bytes()` in the libraries..

I checked the headers and not surprisingly I could not find declarations
for this function either. I have had similar problem with other glib
functions before too, most of the functions from the man page work, but
some not.

What should I do?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


guchar * sometimes a utf8, sometimes utf16?

2018-06-01 Thread Leo Ufimtsev
Hello guys,

The following method:
guchar * webkit_web_resource_get_data_finish(..)

Sometimes returns utf8 and sometimes utf16. Is there a way to tell them
apart?

Thank you.

-- 
Leo Ufimtsev, Software Engineer, Red Hat
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Can a GtkApplicationWindow have both a menubar AND a toolbar?

2018-06-01 Thread c . buhtz
Please show us a minimal working example. Give us code to show us what 
you have tried so far.


And doesn't it had to be a GtkApplicationWindow? Why not using a simpler 
GtkWindow?

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