How to create a window like Google Chrome in GTK +

I am new to GTK libraries and am trying to develop a small project in GTK + 2 with its C API. The requirement is to do this in a Google-Chrome window. It will have its own title bar and controls with different colors.

Can someone help me with any tutorial or link or any open source code that has already implemented this?

I appreciate your help.

+4
source share
5 answers

What you want to do is custom decoration.

My understanding is that you need to set the value of a certain False in the window so that WM does not add the border of the title bar / title to your windows, and then you have your own custom subclass of Window that processes the drawings themselves manually in paint() .

Not trivial.

+5
source

Since the Crhomium browser is an open source project, its source is available here: http://src.chromium.org/viewvc/chrome/trunk/

What you are looking for should by definition be available there :)

+5
source

what you might be looking for is an example of a gtk car. It shows you how to create a formatted window using an xpm file. C, Perl, and Python have an example. I made one of them a few years ago, but have not used it for some time.

Here is the C version ...

Python example here ...

Here's a bitmap and GTK + tutorial

Just create your image using Gimp and save it as an xpm file.

+2
source

By adding a 246tNt response, Chrome uses Skia. Here is an example (Gtk + 3, cairo, skia):

  g_signal_connect(window_container_, "draw", G_CALLBACK(OnWindowContainerDraw), NULL); gboolean OnWindowContainerDraw(GtkWidget* widget, cairo_t *cr) { SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); bitmap.allocPixels(); SkDevice device(bitmap); SkCanvas canvas(&device); SkPaint paint; SkRect r; paint.setARGB(255, 255, 255, 255); r.set(10, 10, 20, 20); canvas.drawRect(r, paint); cairo_surface_t* surface = cairo_image_surface_create_for_data( (unsigned char*)bitmap.getPixels(), CAIRO_FORMAT_ARGB32, bitmap.width(), bitmap.height(), bitmap.rowBytes()); cairo_surface_mark_dirty(surface); cairo_set_source_surface(cr, surface, 0, 0); cairo_paint(cr); return FALSE; } 
0
source

I'm a little confused about what you are actually looking for, but I think you need a control that provides a web browser inside your window.

WebKitGTK + is one such control: http://webkitgtk.org/

GtkMozEmbed is different: http://www.mozilla.org/unix/gtk-embedding.html

The last time I did this, I had to try several to find the one that worked. The controls have different errors and support HTML (and Flash.)

-1
source

Source: https://habr.com/ru/post/1337735/


All Articles