Re.: GtkDrawingArea size request

2017-06-22 Thread Rúben Rodrigues
Solved.

Someone have a example of how to create a custom widget with cairo in C?
Thanks

 Mensagem original 
Assunto: Fwd: GtkDrawingArea size request
De: Rúben Rodrigues
Para: gtk-app-devel-list@gnome.org
CC:

Someone received my question?

Thanks


 Mensagem reencaminhada 
Assunto:GtkDrawingArea size request
Data:   Wed, 21 Jun 2017 10:08:15 +0100
De: Rúben Rodrigues 
Para:   gtk-app-devel-list@gnome.org 




Hi,

I create a drawing area to draw a circular gauge with cairo.

GtkWidget *drawing_area = gtk_drawing_area_new ();
gtk_widget_set_size_request (drawing_area, 100, 100);
gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder,
"box30")),drawing_area,FALSE,TRUE,0);

The problem is that the drawing area is not 100x100 but the entire of
screen.

This is the callback function:



gboolean on_circular_gauge_draw(GtkWidget *widget, cairo_t *cr,
gpointer user_data)
{

  int width, height;
  gint percentage, linewidth;

  width = gtk_widget_get_allocated_width (widget);
  height = gtk_widget_get_allocated_height (widget);


  linewidth = (MIN (width, height) / 2.0 * 30.0) / 100.0;

  cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
  cairo_set_line_width (cr, linewidth);
  cairo_arc(cr, width/2.0, height/2.0,  MIN (width, height) / 2.0 -
linewidth, angle1, angle2);
  cairo_stroke (cr);

  cairo_set_source_rgba (cr, 0.0, 0.9, 0.0, 1.0);
  cairo_set_line_width (cr, linewidth);
  cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0  -
linewidth, 180.0  * (M_PI/180.0),315.0  * (M_PI/180.0) );
  cairo_stroke (cr);



  return FALSE;
}



[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]
  Sem vírus. 
www.avast.com
___
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: Header bar: Keyboard accessibility?

2017-06-22 Thread Michael Torrie
On 06/22/2017 12:03 PM, Yuri Khan wrote:
> And now for the title question. In this latter scenario, how does the
> user access the application menu without having to use a pointing
> device? Is every application supposed to implement that? As a
> developer, how would I go about that? As a user, what do I say in the
> bug report when an application neglects this?

All the Gnome 3 apps that use a header bar that I have at my disposal
let me open the application menu with F10.  Even when I run the app
under the most primitive window manager out there, TWM.  Are they doing
something different than your app?


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


Re: Combobox disable item

2017-06-22 Thread Eric Cashon via gtk-app-devel-list

 

 
Hi Mike,

What part of the combo box are you trying to disable? If you want to filter 
rows or columns you can set up a tree model filter to do so. Maybe something 
like the following?

Eric


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

static gint combo_row=0;

static void change_combo(GtkComboBox *combo2, gpointer *data)
  {
combo_row=gtk_combo_box_get_active(combo2);
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(data[1]));
gtk_combo_box_set_active(GTK_COMBO_BOX(data[0]), 0);
  }
static gboolean show_rgb(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
  {
gchar *string=gtk_tree_model_get_string_from_iter(model, iter);
gint row=atoi(string);
g_free(string);

if(combo_row==1&<3)
  {
g_print("Combo1 Don't Show %i\n", row);
return FALSE;
  }
else
  { 
g_print("Combo1 Show %i\n", row);
return TRUE;
  }
  }
int main(int argc, char *argv[])
  {
gtk_init(, );

GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Combo Filter");
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 300, 100);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

GtkTreeIter iter;
GtkListStore *store=gtk_list_store_new(1, G_TYPE_STRING);
gtk_list_store_append(store, );
gtk_list_store_set(store, , 0, "Yellow", -1);
gtk_list_store_append(store, );
gtk_list_store_set(store, , 0, "Purple", -1);
gtk_list_store_append(store, );
gtk_list_store_set(store, , 0, "Cyan", -1);
gtk_list_store_append(store, );
gtk_list_store_set(store, , 0, "Red", -1);
gtk_list_store_append(store, );
gtk_list_store_set(store, , 0, "Green", -1);
gtk_list_store_append(store, );
gtk_list_store_set(store, , 0, "Blue", -1);

GtkTreeModel *model=gtk_tree_model_filter_new(GTK_TREE_MODEL(store), NULL);
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(model), 
(GtkTreeModelFilterVisibleFunc)show_rgb, NULL, NULL);  

GtkCellRenderer *renderer=gtk_cell_renderer_text_new();

GtkWidget *combo1=gtk_combo_box_new_with_model(model);
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo1), renderer, TRUE);
gtk_widget_set_hexpand(combo1, TRUE);
gtk_widget_set_vexpand(combo1, TRUE);
gtk_combo_box_set_active(GTK_COMBO_BOX(combo1), 0);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo1), 
GTK_CELL_RENDERER(renderer), "text", 0, NULL);

GtkWidget *combo2=gtk_combo_box_text_new();
gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo2), 0, "1", "Show All");
gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo2), 1, "2", "Show RGB");
gtk_combo_box_set_active(GTK_COMBO_BOX(combo2), 0);
gtk_widget_set_hexpand(combo2, TRUE);
gtk_widget_set_vexpand(combo2, TRUE);
gpointer data[]={combo1, model};
g_signal_connect(combo2, "changed", G_CALLBACK(change_combo), data);

g_object_unref(G_OBJECT(store));

GtkWidget *grid=gtk_grid_new();
gtk_grid_attach(GTK_GRID(grid), combo1, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), combo2, 0, 1, 1, 1);
gtk_container_add(GTK_CONTAINER(window), grid);
   
gtk_widget_show_all(window);
gtk_main();
return 0;   
  }



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


Re: Gtk+2 Textview, (editor) compiled on Windows and 'i' interpreted as 'ctrl+i' (indent)?

2017-06-22 Thread David C. Rankin
On 06/21/2017 05:52 AM, David C. Rankin wrote:
> Now all I have to do is figure out how to fix
> gtk_source_language_manager_set_search_path () on windows so it can find my
> sourceview language files in
> "C:\opt\gtk2\share\gtksourceview-2.0\language-specs" 

  The search paths problem was the result of an earlier glib version in the
windows binaries requiring inclusion of glib-object.h and calling
g_type_init(). Resolved by adding a preprocessor check and guard around the
init, e.g.

#ifndef GLIB236
 #include 
#endif
...
#ifndef GLIB236
g_type_init();
#endif

  Are the windows binaries updated on any type of basis? I guess it's just up
to whoever at gnome.org takes an interest. It would be nice to have current
gtk+-2.0, 3.0 and glib versions (actually for all versions of binaries at
https://download.gnome.org/binaries/win32)

Thanks again for your help.

-- 
David C. Rankin, J.D.,P.E.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkDrawingArea size request

2017-06-22 Thread Eric Cashon via gtk-app-devel-list

 
Hi Ruben, 

You might consider allowing the gauge to expand with the window size. This 
makes the gauge a lot more flexible. When drawing a gauge it is useful to get a 
general coordinate drawing on screen that you can check your gauge drawing 
with. Both cartesian coordinates and radial coordinates are useful to check 
your drawing. There is a general layout drawing in the following.

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/cairo_drawings/gears2.c

You can use set sizes if you want to also. To keep your drawing area window 
size a set size check your vexpand and hexpand properties. Make sure they are 
false. Try using a GtkGrid instead of a GtkBox. Put the drawing area in a 
scrolled window and put that in the grid.

I have done some work drawing gauges and have a couple packaged as widgets. 
There are also some drawings of clocks, gauges, gems and gears in the above 
github cairo_drawings folder. Some resize as circles and some as ellipses. They 
might be helpful getting something that you can test a gauge drawing with.

Eric

 


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


Header bar: Keyboard accessibility?

2017-06-22 Thread Yuri Khan
Hello everybody.

I have heard of desktop environments that display the application menu
in a dedicated place (GNOME Shell, OS X). Presumably, in that case the
desktop environment provides a key that the user can press to open the
application menu.

I am not on such a system. That means every GTK application has to
display its menu in its own window.

There are basically two ways to do that. By default,
GtkApplicationWindow displays a menu bar with the application menu as
its first menu. In this case, F10 opens the menu.

Another way is to add a GtkHeaderBar to the window, call
gtk_application_window_set_show_menubar(false) and
gtk_header_bar_set_show_close_button(true). In this case, the header
bar shows an unfocusable button that, when clicked, displays the
application menu.


And now for the title question. In this latter scenario, how does the
user access the application menu without having to use a pointing
device? Is every application supposed to implement that? As a
developer, how would I go about that? As a user, what do I say in the
bug report when an application neglects this?

In a demo application, I was able to add an F10 accelerator to a
window action that walks the widget tree of the header bar and
activates the first GtkMenuButton it finds, but this really screams
“implementation details” and “support nightmare”.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

GtkDrawingArea size request

2017-06-22 Thread Rúben Rodrigues
Hi,

I create a drawing area to draw a circular gauge with cairo.

GtkWidget *drawing_area = gtk_drawing_area_new ();
 gtk_widget_set_size_request (drawing_area, 100, 100);
 gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder, 
"box30")),drawing_area,FALSE,TRUE,0);

The problem is that the drawing area is not 100x100 but the entire of 
screen.

This is the callback function:



gboolean on_circular_gauge_draw(GtkWidget *widget, cairo_t *cr,
 gpointer user_data)
{

   int width, height;
   gint percentage, linewidth;

   width = gtk_widget_get_allocated_width (widget);
   height = gtk_widget_get_allocated_height (widget);


   linewidth = (MIN (width, height) / 2.0 * 30.0) / 100.0;

   cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
   cairo_set_line_width (cr, linewidth);
   cairo_arc(cr, width/2.0, height/2.0,  MIN (width, height) / 2.0 - 
linewidth, angle1, angle2);
   cairo_stroke (cr);

   cairo_set_source_rgba (cr, 0.0, 0.9, 0.0, 1.0);
   cairo_set_line_width (cr, linewidth);
   cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0  - 
linewidth, 180.0  * (M_PI/180.0),315.0  * (M_PI/180.0) );
   cairo_stroke (cr);



   return FALSE;
}


---
Este e-mail foi verificado em termos de vírus pelo software antivírus Avast.
https://www.avast.com/antivirus

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

Combobox disable item

2017-06-22 Thread Mike Martin
Hi

Is it possible to disable an item in a combobox?

I cant find anything about this, set_sensitive only seems to apply to
either cell-renderer or widget

thanks

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