Re: Custom GtkHeaderBar

2017-04-15 Thread Eric Cashon via gtk-app-devel-list

I gave it another try and "header" gtk_style_context_add_class() is 
transparent. I can use "menu" and that returns a darker color that is used on 
the title bar. 

It is C again. I did get foo.vala output to foo.c. Too much stuff. 

Eric

/*
   gcc -Wall box1.c -o box1 `pkg-config --cflags --libs gtk+-3.0`
   Tested with GTK3.18 on Ubuntu16.04
*/
#include

static gboolean draw_main_window(GtkWidget *widget, cairo_t *cr, gpointer data);
static gboolean draw_event_box(GtkWidget *widget, cairo_t *cr, gpointer data);
static void close_program(GtkWidget *widget, gpointer user_data);

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), "Title Bar");
gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_widget_set_app_paintable(window, TRUE);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(window, "draw", G_CALLBACK(draw_main_window), NULL);

GtkWidget *button=gtk_button_new_with_label("Close");
g_signal_connect(button, "clicked", G_CALLBACK(close_program), NULL);

GtkWidget *label1=gtk_label_new("Header");
gtk_label_set_markup(GTK_LABEL(label1), "Header");
GtkWidget *label2=gtk_label_new("Bar");
gtk_label_set_markup(GTK_LABEL(label2), "Bar");   

GtkWidget *box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_set_border_width(GTK_CONTAINER(box), 10);
gtk_widget_set_hexpand(box, TRUE);
gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(box), label1, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(box), label2, TRUE, TRUE, 0);
   
GtkWidget *event=gtk_event_box_new();
GtkStyleContext *context=gtk_widget_get_style_context(event);
//Use the menu background.
gtk_style_context_add_class(context, "menu");
gtk_container_add(GTK_CONTAINER(event), box);
g_signal_connect(event, "draw", G_CALLBACK(draw_event_box), NULL);
gtk_window_set_titlebar(GTK_WINDOW(window), event);

GtkWidget *label3=gtk_label_new("Main");
gtk_widget_set_vexpand(label3, TRUE);
gtk_widget_set_hexpand(label3, TRUE);
GtkWidget *label4=gtk_label_new("Window");
gtk_widget_set_vexpand(label4, TRUE);
gtk_widget_set_hexpand(label4, TRUE); 

GtkWidget *grid=gtk_grid_new();
gtk_grid_attach(GTK_GRID(grid), label3, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), label4, 0, 1, 1, 1);  

gtk_container_add(GTK_CONTAINER(window), grid);

gtk_widget_show_all(window);

gtk_main();

return 0;
  }  
static gboolean draw_main_window(GtkWidget *widget, cairo_t *cr, gpointer data)
  {
//Paint the main window.
cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
cairo_paint(cr);
return FALSE;
  }
static gboolean draw_event_box(GtkWidget *widget, cairo_t *cr, gpointer data)
  {
//Paint the event box header bar.
gint width=gtk_widget_get_allocated_width(widget);
gint height=gtk_widget_get_allocated_height(widget);

GtkStyleContext *context=gtk_widget_get_style_context(widget);
gtk_render_background(context, cr, 0, 0, width, height);

return FALSE;
  }
static void close_program(GtkWidget *widget, gpointer user_data)
  {
gtk_main_quit();
  }




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


Re: Custom GtkHeaderBar

2017-04-15 Thread Eric Cashon via gtk-app-devel-list

Well I made a mess of that. I haven't worked with Vala and thought that looked 
like C#. I have some time on the weekend so I will have to take a look at Vala 
and run your code so I understand it better.

I can get the theme color with gtk_widget_get_style_context() if I have a 
GtkHeaderBar. If I don't have a GtkHeaderBar widget I don't know how to get the 
theme color for the header bar. Something else I haven't figured out yet. If 
you get that figured out I would like to know myself.

Another option for a custom GtkHeaderBar is to use an event box and put the 
horizontal box in it. That way you have the event box window and can draw the 
background a little easier.

Eric



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


Re: Custom GtkHeaderBar

2017-04-15 Thread Takao Fujiwara

On 04/15/17 04:36, cecas...@aol.com-san wrote:


I suspect

set_titlebar(header);

is causing the problem. If you remove that, then you will have a box that you 
place in the main window. If it is a header bar box it will be below the
titlebar. The box itself is just doing the layout so it uses the window behind 
it. You can draw on the window with a style context like

GtkStyleContext *context=gtk_widget_get_style_context(GTK_WIDGET(widget));
gtk_render_background(context, cr, 0, 0, width, height+20);


Probably I think it cannot get the theme color of GtkHeaderBar.



to get a specific widget color instead of setting the color with cairo.

A little limited here since I don't have a C# setup and am using GTK3.18 which 
doesn't have all the 3.22 functions. What OS are you using and how did
you setup C# for programming with?

Eric


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


Re: Custom GtkHeaderBar

2017-04-15 Thread Takao Fujiwara

On 04/16/17 00:05, Takao Fujiwara-san wrote:

On 04/15/17 04:36, cecas...@aol.com-san wrote:

A little limited here since I don't have a C# setup and am using GTK3.18 which 
doesn't have all the 3.22 functions. What OS are you using and how did
you setup C# for programming with?


Sorry, ignored this question. Now I understood what you asked.
It was a Vala code but not C#.


You can output C code by `valac --ccode foo.vala --pkg gtk+-3.0`
I wrote the vala code because I think it easily show the example of the 
inherited class.



Fujiwara



Eric


___
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: Custom GtkHeaderBar

2017-04-15 Thread Takao Fujiwara

On 04/15/17 04:36, cecas...@aol.com-san wrote:

A little limited here since I don't have a C# setup and am using GTK3.18 which 
doesn't have all the 3.22 functions. What OS are you using and how did
you setup C# for programming with?


Sorry, ignored this question. Now I understood what you asked.
It was a Vala code but not C#.

Fujiwara



Eric


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


guile 2.0 / ghci REPL integration

2017-04-15 Thread PICCA Frederic-Emmanuel
Hello,

I am developping a C application using GTK3 on Debian stretch.

I would like to add a REPL into it (ghkl, which is a diffractometer control 
application).
I know about haskell, so it would be nice to have ghci integrated into it.
But if necessary I could have a look at guile-2.0, whch dos not seems bad at 
all for this purpose.

I just need to write things like

traj hkl 1 1 1 1 2 3 100
ca hkl 1 1 1
mv omega 4
mv
etc...

Do you have examples of this kind of integration in gtk3 applications ?

thanks for yur help

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