GTK TreeView change the column header color

2015-06-13 Thread Juan L. Freniche
I am trying to change the color of the column headers of a treeview, 
with no sucess at all. I followed the way indicated in an old post in 
Nov. 2003:


I tried:
for each column in the treeview:
when defining the column, set_widget (col, label)
now show the widget (i.e., the label).
Then  show the treeview.
And now:
for each column in the treeview:
get_widget (col)
get_parent // the alignment
get_parent // the hbox
get_parent // the button
modify bg (button, state normal, some gdk color) // tried 
also with modify base

Result: nothing, header columns blank

I also tried in the rc file (still using gtk 2.xx):
style TreeHeaderStyle
 {
  bg[NORMAL] = blue  # tried also with base
 }
widget_class *.GtkTreeView.GtkButton style : highest TreeHeaderStyle

Result: nothing, header columns still blank

The global gtkrc is the default one and my particular gtkrc is
# Auto-written by gtk2_prefs. Do not edit.
gtk-theme-name = Nimbus
style user-font
{
font_name=Sans 10
}
widget_class * style user-font

I change the theme to several others and no success.
I know that some years ago the same question was made, I followed the 
recommendations given there. No success.


I would appreciate any help. Thanks.
Ah, in Win32.

I am attaching a small program derived from an example in the treeview 
tutorial

- the program -
#include gtk/gtk.h

enum
{
  COL_FIRST = 0,
  NUM_COLS
} ;

static GtkTreeModel *create_and_fill_model (void)
{
  GtkTreeStore  *treestore;
  GtkTreeItertoplevel;

  treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_STRING);

  gtk_tree_store_append(treestore, toplevel, NULL);
  gtk_tree_store_set(treestore, toplevel, COL_FIRST, some text, -1);

  gtk_tree_store_append(treestore, toplevel, NULL);
  gtk_tree_store_set(treestore, toplevel, COL_FIRST, more text, -1);

  return GTK_TREE_MODEL(treestore);
}

void set_header (GtkTreeViewColumn *col, char *title)
{ GtkWidget *lab;

  lab = gtk_label_new (title);
  gtk_tree_view_column_set_widget (col, lab);
  gtk_widget_show (lab);
}

void set_color (GtkWidget *w, GdkColor color)
{ /* none work */
  gtk_widget_modify_bg   (w, GTK_STATE_NORMAL,  color);
  gtk_widget_modify_base (w, GTK_STATE_NORMAL,  color);
  gtk_widget_modify_bg   (w, GTK_STATE_ACTIVE,  color);
  gtk_widget_modify_base (w, GTK_STATE_ACTIVE,  color);
  gtk_widget_modify_bg   (w, GTK_STATE_PRELIGHT,color);
  gtk_widget_modify_base (w, GTK_STATE_PRELIGHT,color);
  gtk_widget_modify_bg   (w, GTK_STATE_PRELIGHT,color);
  gtk_widget_modify_base (w, GTK_STATE_PRELIGHT,color);
  gtk_widget_modify_bg   (w, GTK_STATE_SELECTED,color);
  gtk_widget_modify_base (w, GTK_STATE_SELECTED,color);
  gtk_widget_modify_bg   (w, GTK_STATE_INSENSITIVE, color);
  gtk_widget_modify_base (w, GTK_STATE_INSENSITIVE, color);
}

void set_color_header (GtkTreeView *view)
{
  GtkTreeViewColumn *col;
  GtkWidget *w;
  GdkColor  color;
  gboolean  res;

  res = gdk_color_parse (red, color);
  if (res == 0) return;
  col = gtk_tree_view_get_column (view, COL_FIRST);

  w = gtk_tree_view_column_get_widget (col); /* the label */
  /* set_color (w, color); NOK*/

  w = gtk_widget_get_parent (w); /* the alignment */
  /* set_color (w, color); NOK*/

  w = gtk_widget_get_parent (w); /* the hbox */
  /* set_color (w, color); NOK*/

  w = gtk_widget_get_parent (w); /* the button */
  set_color (w, color); /* NOK */
}

static GtkWidget *create_view_and_model (void)
{
  GtkTreeViewColumn   *col;
  GtkCellRenderer *renderer;
  GtkWidget   *view;
  GtkTreeModel*model;

  view = gtk_tree_view_new();

  col = gtk_tree_view_column_new();
  set_header (col, First Column);
  renderer = gtk_cell_renderer_text_new();
  gtk_tree_view_column_pack_start(col, renderer, TRUE);
  gtk_tree_view_column_add_attribute(col, renderer, text, COL_FIRST);
  gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);

  /* set_color_header(GTK_TREE_VIEW(view));  NOK */

  model = create_and_fill_model();

  gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);

  g_object_unref(model);

  return view;
}

int main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *view;

  gtk_init(argc, argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  g_signal_connect(window, delete_event, gtk_main_quit, NULL); /* 
dirty */


  view = create_view_and_model();
  /*  set_color_header(GTK_TREE_VIEW(view)); NOK */

  gtk_container_add(GTK_CONTAINER(window), view);

  gtk_widget_show_all(window);

  set_color_header(GTK_TREE_VIEW(view)); /* NOK */

  gtk_main();

  return 0;
}
 the Makefile ---

CC = gcc

CFLAGS = -g -O0 `pkg-config --cflags gtk+-2.0`

all: treeview-demo

treeview-demo: main.o
   

Gtk TreeView emits a beep

2013-11-07 Thread raum
Hello,

I'm programming a tool using Vala langage. I need to manipulate a
treeview, delete an item for example.

I'm trapped the release key event but for certain keys, treeview emits a
beep (left or right arrow, del keys).

How can I remove this beep ?

 CODE sample.vala 
public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = My Gtk.TreeView;
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (350, 70);

// The Model:
Gtk.ListStore list_store = new Gtk.ListStore (2, typeof 
(string));
Gtk.TreeIter iter;

list_store.append (out iter);
list_store.set (iter, 0, Burgenland);
list_store.append (out iter);
list_store.set (iter, 0, Carinthia);
list_store.append (out iter);
list_store.set (iter, 0, Lower Austria);
list_store.append (out iter);
list_store.set (iter, 0, Upper Austria);

// The View:
Gtk.TreeView view = new Gtk.TreeView.with_model (list_store);
this.add (view);

Gtk.CellRendererText cell = new Gtk.CellRendererText ();
view.insert_column_with_attributes (-1, State, cell, text, 
0);

view.add_events(Gdk.EventMask.KEY_RELEASE_MASK);
view.key_release_event.connect(on_key_press);
}

public  bool on_key_press (Gdk.EventKey event) {
stdout.printf (keyval: %lu  hk: %lu\n, event.keyval,
event.hardware_keycode);
return true;
}

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}


### Compilation ##
$ valac --pkg gtk+-3.0 sample.vala

Thanks

Regards

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


GTK+ TreeView: Different CellRenderers on the same Column

2011-10-17 Thread Stefan Salewski
I am working on a configuration file editor for an graphical
application. Configuration consists of strings, numbers and boolean
values. About 25 values total.

I can use individual widgets for each property, but for larger
quantities a listview is a more compact form.

It would we nice to have textentry fields for strings, spin buttons for
numbers and check boxes for boolean values, all in one column of the
tree view.

Of course I can pop up dialog windows whenever the user clicks on an row
of the treeview, but that is not a nice solution when the user wants to
change more than one value.

With Google, I found some people asking for this, but only one
complicated solution:

http://kapo-cpp.blogspot.com/2008/05/different-cellrenderers-on-same-column.html

I think it is too complicated for me now, not being an GTK expert. (And
I am using the Ruby GTK bindings, which may make it difficult to use the
above solution.)

Is there a better solution or even an example available?

Best Regards,

Stefan Salewski


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


Re: GTK+ TreeView: Different CellRenderers on the same Column

2011-10-17 Thread Colomban Wendling
Le 17/10/2011 13:53, Stefan Salewski a écrit :
 I am working on a configuration file editor for an graphical
 application. Configuration consists of strings, numbers and boolean
 values. About 25 values total.
 
 I can use individual widgets for each property, but for larger
 quantities a listview is a more compact form.
 
 It would we nice to have textentry fields for strings, spin buttons for
 numbers and check boxes for boolean values, all in one column of the
 tree view.
 
 Of course I can pop up dialog windows whenever the user clicks on an row
 of the treeview, but that is not a nice solution when the user wants to
 change more than one value.
 
 With Google, I found some people asking for this, but only one
 complicated solution:
 
 http://kapo-cpp.blogspot.com/2008/05/different-cellrenderers-on-same-column.html
 
 I think it is too complicated for me now, not being an GTK expert. (And
 I am using the Ruby GTK bindings, which may make it difficult to use the
 above solution.)
 
 Is there a better solution or even an example available?

Not sure it's better (actually I just took a small glance at the link),
but there are other solutions.

First, the one used by gconf-editor [1], that consist of a custom cell
renderer that provides the appropriate editable depending on the type of
the value it holds.  This is not necessarily the easier way, but it's
quite interesting IMHO.

The other solution I know is to pack all CellRenderer that might be used
for editing, and only make one visible/sensitive, depending on the row's
value type.  This is what we current use in the implementation of
Geany's stash editor [2], [3].


IMHO the second solution is the easier one, nut sure it's the bast
though.  Hope it helps.

Regards,
Colomban


[1] http://git.gnome.org/browse/gconf-editor/tree/src/gconf-cell-renderer.c
[2] https://github.com/geany/geany/blob/master/src/stash.c#L910
[3] https://github.com/geany/geany/blob/master/src/stash.c#L1051
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK+ TreeView: Different CellRenderers on the same Column

2011-10-17 Thread Stefan Salewski
On Mon, 2011-10-17 at 15:11 +0200, Colomban Wendling wrote:

 [...]
 The other solution I know is to pack all CellRenderer that might be used
 for editing, and only make one visible/sensitive, depending on the row's
 value type.  This is what we current use in the implementation of
 Geany's stash editor [2], [3].
 

Thanks, that sound very promising and not too difficult.
I was aware that I can pack multiple renderer in the same tree view
column, but I was not aware that I can hide them totally using a
cell_data_func.

Best regards,

Stefan Salewski


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


Re: gtk treeview windows

2009-02-07 Thread Matthew Talbert
 Oh, sorry. I assume you have verified that you don't have any heap
 corruption by running the code under valgrind on Linux? Other than
 that I really can't give any specific advice. Perhaps ask somebody
 else to read the code carefully. If the problem did not occur at some
 earlier stage, then you could do a binary search through your version
 history to find the exact changes that made the problems occur. But if
 the problem happens very randomly and rarely, of course that is going
 to be tedious, as you can never be sure if one version really is
 clean, or if the problem just happens not to occur when you test that
 version.

 --tml

I still think maybe we're missing each other here. The problem has
never occurred on linux, and the software has run there for several
years, so heap corruption seems unlikely. The problem occurs only on
Windows, and only with the libwimp theme engine. We don't have any
previous versions that worked correctly as this is our first porting
attempt.

What I have done:

Added debugging message code to the test-collapse-row and
test-expand-row signals. As expected these fire correctly when the
treeview is working properly, but they do not fire when the treeview
is locked up. However, using the arrow keys to navigate the treeview,
these signals fire correctly.

We are also connected to the button-release-event for the treeview.
This only fires when clicking on the row, not the button (little plus
symbol) that would expand or collapse the treeview row.

What I would like to know is if there is a signal, or some way I can
detect whether the button is receiving the mouse click, but not
expanding for some reason, or where exactly the problem is occurring.

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


Re: gtk treeview windows

2009-02-07 Thread Larry Reaves
On Sat, 2009-02-07 at 14:25 -0500, Matthew Talbert wrote:
  Oh, sorry. I assume you have verified that you don't have any heap
  corruption by running the code under valgrind on Linux? Other than
  that I really can't give any specific advice. Perhaps ask somebody
  else to read the code carefully. If the problem did not occur at some
  earlier stage, then you could do a binary search through your version
  history to find the exact changes that made the problems occur. But if
  the problem happens very randomly and rarely, of course that is going
  to be tedious, as you can never be sure if one version really is
  clean, or if the problem just happens not to occur when you test that
  version.
 
  --tml
 
 I still think maybe we're missing each other here. The problem has
 never occurred on linux, and the software has run there for several
 years, so heap corruption seems unlikely. The problem occurs only on
 Windows, and only with the libwimp theme engine. We don't have any
 previous versions that worked correctly as this is our first porting
 attempt.
 
It still may be worth your time to run it through valgrind on linux.
Just because it works fine doesn't mean your program has no memory usage
bugs.  If it does, changing platforms is exactly the kind of thing that
would make such an error present itself.

-Larry
la...@yrral.net

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


Re: gtk treeview windows

2009-02-06 Thread Tor Lillqvist
 Not trying to be offensive, but if I could reproduce this every time,
 I wouldn't be asking for debugging suggestions.

Oh, sorry. I assume you have verified that you don't have any heap
corruption by running the code under valgrind on Linux? Other than
that I really can't give any specific advice. Perhaps ask somebody
else to read the code carefully. If the problem did not occur at some
earlier stage, then you could do a binary search through your version
history to find the exact changes that made the problems occur. But if
the problem happens very randomly and rarely, of course that is going
to be tedious, as you can never be sure if one version really is
clean, or if the problem just happens not to occur when you test that
version.

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


gtk treeview windows

2009-02-05 Thread Matthew Talbert
Hi all,

I am a developer for Xiphos (previously GnomeSword) and I'm heavily
involved in our Windows port effort. Most things have gone smoothly,
but one issue really has me stumped.

Occasionally all of the treeviews in the application will freeze. By
this I mean that they will not expand or collapse with mouse clicks.
They will, however, expand and collapse with the keyboard (arrows,
enter, etc). Additionally, the items themselves respond to mouse
clicks. Very rarely, they will be frozen on startup, but typically it
happens after clicking around on other buttons for a little bit.

We are using the Windows theme for this. I have never been able to
replicate it with the default gtk theme.

I would appreciate any suggestions as to how to debug this further.

Thanks,
Matthew
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk treeview windows

2009-02-05 Thread Tor Lillqvist
 I would appreciate any suggestions as to how to debug this further.

Write a minimal sample program that exhibits the problem, file a bug,
and attach the sample program (as a single source file in C; no
binaries, not zip archives, no makefiles) to the bug.

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


Re: Can I make a not aligned gtk treeview?

2007-12-17 Thread Mikael Hallendal
17 dec 2007 kl. 08.29 skrev Binary Chen:

Hi,

A TreeView will always align the columns. However, to achieve the  
behavior you look for you can pack two cell renderers into the same  
column.

Cheers,
   Mikael Hallendal

 Hi,

 I have a gtktreeview with two column, the first one is pixbuf, the
 second one is a string. something happen bad if in a row the first
 pixbuf is NULL, so it doesn't occupy any place, but in the following  
 row
 there is a pixbuf and occupy some place. the default behavior of
 gtktreeview will align the second column so leave a large blank in  
 first
 row.

 How can I tell treeview not align in different row, but just place the
 column independently?

 Thanks.
 Bin

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

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


Can I make a not aligned gtk treeview?

2007-12-16 Thread Binary Chen
Hi,

I have a gtktreeview with two column, the first one is pixbuf, the
second one is a string. something happen bad if in a row the first
pixbuf is NULL, so it doesn't occupy any place, but in the following row
there is a pixbuf and occupy some place. the default behavior of
gtktreeview will align the second column so leave a large blank in first
row.

How can I tell treeview not align in different row, but just place the
column independently?

Thanks.
Bin

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


GTK treeview very slow?

2007-09-02 Thread Binary Chen
Hi,

I am running GTK treeview in a slow machine, say, with a 200MHz CPU, I
am using a treeview with about 20 nodes as total. When I scroll the
treeview scroll bar, the image get to freeze for a while...

I then try with a simpler table with 1 column, the speed is quite fast,
I can aware the freeze when scrolling.

I want to confirm is my conclution is right? The treeview is
significantly slower then other container?

Thanks.
Bin

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


Re: [Gtk#] TreeView.

2005-09-22 Thread Christian Neumair
Am Dienstag, den 20.09.2005, 20:05 +0200 schrieb Nicolas Cormier:
 I have a Treeview and I want to active the EnterNotifyEvent when a the
 user's cursor is on a row.
 
 I active the EnterNotifyEvent for the treeview but it works only for
 the entire of the widget.

See [1] for a patch against Nautilus which does what you want.

The interesting thing you have to grasp is

a) you only have motion notify events inside a tree view widget
b) you'll have to check what path is active on each motion event
c) the algorithm you can use to detect changes to the hover path, inside
the motion notification handler, where the GdkEventMotion is event, is:

GtkTreePath *hover_path;
GtkTreePath *last_hover_path;

/*  last_hover_path = foo-stored_path; fetch last hover path */
  gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
 event-x, event-y,
 hover_path,
 NULL, NULL, NULL);
/*  foo-stored_path = hover_path; write back new hover path */

  if (!(last_hover_path == NULL  hover_path == NULL) 
  (!(last_hover_path != NULL  hover_path != NULL) ||
gtk_tree_path_compare (last_hover_path, hover_path) != NULL)) {
/* do whatever you want with the new hover path */
  }

[1] http://bugzilla.gnome.org/attachment.cgi?id=49082action=view

-- 
Christian Neumair [EMAIL PROTECTED]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: [Gtk#] TreeView.

2005-09-22 Thread Nicolas Cormier
On 9/22/05, Christian Neumair [EMAIL PROTECTED] wrote:
 Am Dienstag, den 20.09.2005, 20:05 +0200 schrieb Nicolas Cormier:
  I have a Treeview and I want to active the EnterNotifyEvent when a the
  user's cursor is on a row.
 
  I active the EnterNotifyEvent for the treeview but it works only for
  the entire of the widget.

 See [1] for a patch against Nautilus which does what you want.

 The interesting thing you have to grasp is

 a) you only have motion notify events inside a tree view widget
 b) you'll have to check what path is active on each motion event
 c) the algorithm you can use to detect changes to the hover path, inside
 the motion notification handler, where the GdkEventMotion is event, is:

 GtkTreePath *hover_path;
 GtkTreePath *last_hover_path;

 /*  last_hover_path = foo-stored_path; fetch last hover path */
   gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
  event-x, event-y,
  hover_path,
  NULL, NULL, NULL);
 /*  foo-stored_path = hover_path; write back new hover path */

   if (!(last_hover_path == NULL  hover_path == NULL) 
   (!(last_hover_path != NULL  hover_path != NULL) ||
 gtk_tree_path_compare (last_hover_path, hover_path) != NULL)) {
 /* do whatever you want with the new hover path */
   }

 [1] http://bugzilla.gnome.org/attachment.cgi?id=49082action=view

 --
 Christian Neumair [EMAIL PROTECTED]


 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.1 (GNU/Linux)

 iD8DBQBDMsMFWfvsaU5lO4kRArLwAJ4ntJvOAX1iHpHpFDaE4IW3HZLhfwCfWbPq
 aEJFORbT+Kaz4QBG4fYlSNM=
 =O4na
 -END PGP SIGNATURE-





Thanks a lot for your answer.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Gtk# - Treeview

2005-09-20 Thread Nicolas Cormier
Hi,
I have a Treeview and I want to active the EnterNotifyEvent when a the
user's cursor is on a row.

I active the EnterNotifyEvent for the treeview but it works only for
the entire of the widget.

Thanks in advance for your help.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Gtk treeview use with large data sources

2005-09-06 Thread Kim Adil
I have been searching for some time now to figure out how to approach
using gtk treeview ( with a list model) with a sql database. I am using
odbc on multiple platforms , hence gnomedb is not appropriate. Ideally
the scrollwindow will behave as per using the standard list model. My
questions:

(1) should I write a custom list model that I can connect an odbc dsn 
query to the treeview
(2) should I disect gnome-db to find out the professionals approach it
(3) should I give up and page the resultset into pages of 500 row that
can be scrolled easily without

Appreciate any sensible ideas

Thanks
Kim

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