List open modules

2008-03-28 Thread Bastiaan Veelo
Hi,

I would like to know the name of the theme engine that is drawing my 
application. How do I do that? I failed to find a way to get a list of 
open modules.

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


Re: Quitting an application

2008-03-28 Thread Bastiaan Veelo
Sujith wrote:
 Gabriele Greco writes:
   Intercept the delete_event or modify the callback where you do the
   gtk_main_quit() and insert there some thread sync code.
   
   You should take care also when you add the rows to your Tree/ListStore if
   you do that directly from the  thread that scans the db.
   
   I suppose there is a thread since if there isn't one when you quit the main
   loop nothing can crash it (except something you call after gtk_main()) :)
   

 I don't have a separate thread that does the DB scanning.
 The sequence of operations is something like this:

 1 * Init various GUI elements including the track treeview.
 2 * Read the DB and append elements to the treeview.
 3 * call gtk_main() and wait for events.

 Now, if the user quits between 2 and 3, it becomes an issue because gtk_main()
 hasn't been called yet and I can't check for the main loop.
 If gtk_main() has been invoked, I can check for the existence of the mainloop 
 like this:

 while(gtk_events_pending())
   if (gtk_main_iteration_do(FALSE))
   return;
   

I have not checked, but maybe gtk_main_leve() returns 0 if gtk_main() 
has not been called yet? If that would be of any help.

 Is spawning a thread and cooking up some simple synchronization scheme the 
 only
 way to quit gracefully ?

 thanks,
 Sujith
 ___
 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


Re: sliding panel

2008-03-24 Thread Bastiaan Veelo
I think the problem is that no events are handled as long as you stay in 
your loop, i.e., the GTK loop is not visited. Change the usleep line with

while (gtk_events_pending ()) gtk_main_iteration ();

and see what happens.

Regards,
Bastiaan.

Kevin DeKorte wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 I'd like to create a panel that slides out of the way, little animation
 kinda thing and I had something working but gtk really didn't slide it
 out of the way it just showing the first and then the last. Now I
 understand that due to performance that not every panel change should be
 drawn but any idea how I can do this...

 what I have is this

 An hbox that contains a fixed and then a vbox.. and I want to be able to
 shrink the vbox away..

 so I put in a loop code that set the size of the vbox smaller until it
 got to 1. I was able to see the first state and the state where the vbox
 was down to 1 but I didn't see any of the steps in between. I even tried
 put a g_usleep in there to see it and I wasn't able to see the box
 shrinking.

 I had something like this

   gdk_window_get_geometry(controls_box-window, 
 x, y, width,
 height, NULL);
 rect.x = x;
 rect.y = y;
 rect.width = width;
 for (i = height ; i  0; i--) {
   rect.height = i;
   gtk_widget_set_size_request(controls_box,width,i);  
   gdk_window_invalidate_rect(controls_box-window,rect,TRUE);
   g_usleep(1000);
 }

 Thanks,

 Kevin


 - --
 Get my public GnuPG key from
 http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x7D0BD5D1
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.8 (GNU/Linux)
 Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

 iEYEARECAAYFAkfnzagACgkQ6w2kMH0L1dEwgQCdHigKEknXHYrEXNyXwXgmauTw
 4l4AoIPHBIbCiZrXFN6vkMymthDX9pFz
 =f16u
 -END PGP SIGNATURE-
 ___
 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


Re: toolButton Disable

2008-03-23 Thread Bastiaan Veelo
gtk_widget_set_sensitive() probably does what you want.

Regards,
Bastiaan.

Luiz Rafael Culik Guimaraes wrote:
 Dear Friends

 Is their an way to disable an specific tool buton like the winapi?

 I read the docs, but could not find an reference

 Regards
 Luiz
   

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


Re: How do I spawn an unknown viewer for a known file?

2008-03-09 Thread Bastiaan Veelo
Thank you Allin and James, I will differentiate per platform then.

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


How do I spawn an unknown viewer for a known file?

2008-03-08 Thread Bastiaan Veelo
Hi,

What is the platform independent way to spawn a viewer for, say, a PDF 
document?

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


Re: Printing

2008-02-27 Thread Bastiaan Veelo
Bastiaan Veelo wrote:
 Enrico Tröger wrote:
   
 8) When exporting to PDF on Windows, trying to overwrite an existing 
 file, the program crashes (oops!). This works fine on Linux.
 
   
 I can't reproduce this, on my Windows 2000 box I can overwrite existing
 files as expected.
   
 

 Now I cannot reproduce either. I don't know what went wrong.
OK, now I know. The crash happens when writing to a file that is 
currently open for reading, and that is because I did not check the 
cairo status. Sorry, my mistake.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Printing

2008-02-22 Thread Bastiaan Veelo
Hi Enrico,

I reported a bug on this. You can leave a note that you are able to 
reproduce this, and maybe mention your printer model and Windows 
version. See http://bugzilla.gnome.org/show_bug.cgi?id=518052

Thanks,
Bastiaan.

Enrico Tröger wrote:
  
   
 7) When printing under Windows to a Canon inkjet, the bounding rectangle 
 of graphics (not text) is filled black (auch!). The PDF is printed OK. 
 
 I have the same problem, it is also black when the document is printed
 to a PDF printer on Windows (e.g. PDFCreator from
 http://www.pdfforge.org/).
   


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


Re: Printing

2008-02-22 Thread Bastiaan Veelo
Enrico Tröger wrote:

 8) When exporting to PDF on Windows, trying to overwrite an existing 
 file, the program crashes (oops!). This works fine on Linux.
 
 I can't reproduce this, on my Windows 2000 box I can overwrite existing
 files as expected.
   

Now I cannot reproduce either. I don't know what went wrong.


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


Printing

2008-02-13 Thread Bastiaan Veelo

Dear list,

In lack of a complete printing tutorial,  I wrote one myself. There are 
still some open questions though. My objective is to get consistent 
output of text and graphics on screen, in PDF and printed on paper, 
cross platform. All drawing code is in one function, which should not 
need to know the properties of the current device. I do that by scaling 
the cairo context so user space units are in millimeters.


You will find the code attached, these are the issues:

1) In order to get approximately correctly scaled text I had to specify 
a resolution of around 27.2 on the pango context. This value was 
determined by trial and error. I suspect I am doing something 
fundamentally wrong, and I would like to know how to render text the way 
the font designer inteded it. I have tried scaling only graphics and not 
text, but even then text was much too big.


2) The printed font seems a little heavy. This may be due to the scaling 
issue above.


3) Some letters seem to be placed too close to each other. On my Linux 
screen with the Sans font this is most notable between the r and o in 
brown and o and x in fox. On Windows the problems are at other 
places. I have tried to rule out hinting problems by switching off all 
hinting.


4) When trying to print under Linux, nothing happens. No print job is 
spooled. No message on the console. I can produce a preview which looks 
OK. Not sure whether this is because GTK+ assumes some command line tool 
to be present, like lpr. CUPS is operational on my system.


5) When printing under Windows to an HP LaserJet (PCL and PS) there is a 
positive offset of a few millimeters both horizontally and vertically. 
Printing the PDF is OK.


6) When printing under Windows to an HP LaserJet, the cairo_rectangle is 
not printed. It is when printing the PDF.


7) When printing under Windows to a Canon inkjet, the bounding rectangle 
of graphics (not text) is filled black (auch!). The PDF is printed OK. 
On the laserjet the bounding box is first cleared to white, visible when 
the example on [1] is printed.


8) When exporting to PDF on Windows, trying to overwrite an existing 
file, the program crashes (oops!). This works fine on Linux.


9) The issue of margins. I know that the margins dealt with in the API 
are intended to be used as printer margins, not document margins. 
However, on Windows it is natural to use them as document margins, 
because the interface to modifying them appears on a high level, 
directly in the page setup dialog. These can be modified independently 
from the paper dimensions, and the graphical representation gives the 
user the impression of adjusting document margins, with dynamically 
updated lines printed inside a dashed rectangle. The label does not 
inform the user either that the margins presented are supposed to be 
printer margins, and why would a user be interested to adjust these 
indeed? In most cases the user is only interested in document margins, 
and these should be limited to the printer margins which should stay 
outside the user's control.
On Linux the interface is quite different, here using these margins as 
document margins makes no sense. The interface to adjusting these 
margins is nested on a deeper level, and is coupled to the definition of 
a custom paper size. So the user cannot define the margins without 
defining a custom paper size.
It is my feeling that there is confusion between paper setup and page 
setup. Linux implements paper setup with printer margins that are 
dependent on the printer and paper size, and Windows implements page 
setup with a choice of paper size and document margins. I think the 
Linux implementation is more correct (although the name GtkPageSetup is 
misleading), and that the exposure of the margins on Windows is a 
mistake. As it is, I think the page setup dialog is unsuitable not be 
used in cross platform applications.
However, a widget for adjusting document margins like the current 
Windows presentation would be nice, but then consistent accross platforms.



I hope we can work out all these issues, so the community can have a 
working tutorial and I can get on with my project :-) Probably I should 
file a bug for some of these issues, but maybe the list can correct my 
errors first...


Thanks,
Bastiaan.

[1] http://library.gnome.org/devel/gtk/stable/GtkPrintContext.html
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Printing

2008-02-13 Thread Bastiaan Veelo
Enrico Tröger wrote:
 You will find the code attached, these are the issues:
 
 I don't ;-(.

   

Let's try inline then:



/* February 2008, Bastiaan Veelo, [EMAIL PROTECTED] */

#include gtk/gtk.h
#include cairo.h
#ifdef CAIRO_HAS_PDF_SURFACE
#include cairo-pdf.h
#endif

static GtkWidget *window = NULL;
static GtkPrintSettings *settings = NULL;
static GtkPageSetup *page_setup = NULL;
static gdouble scale100 = -1;
static GtkWidget *font_button = NULL;

static void
begin_print (GtkPrintOperation *operation, GtkPrintContext *context, 
gpointer user_data)
{
  gtk_print_operation_set_n_pages (operation, 1);
}


/* We draw in mm, with (0,0) being the top left corner of the text area. */
static void
draw_page (cairo_t *cr)
{
  g_return_if_fail (page_setup != NULL);

  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_rectangle (cr,
   0,
   0,
   100,
   100);
  cairo_set_line_width (cr, .2);
  cairo_stroke (cr);

  /* Draw some lines */
  cairo_move_to (cr, 0, 0);
  cairo_line_to (cr,
 gtk_page_setup_get_page_width (page_setup, GTK_UNIT_MM),
 gtk_page_setup_get_page_height (page_setup, GTK_UNIT_MM));
  cairo_move_to (cr, 0, gtk_page_setup_get_page_height (page_setup, 
GTK_UNIT_MM));
  cairo_line_to (cr, gtk_page_setup_get_page_width (page_setup, 
GTK_UNIT_MM), 0);

  cairo_set_line_width (cr, 1);
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
  cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);

  cairo_stroke (cr);

  PangoFontDescription *desc =
  pango_font_description_from_string (gtk_font_button_get_font_name 
(GTK_FONT_BUTTON (font_button)));

  const gdouble dpi = 27.2; /*  Misterious empirical value. */
  PangoLayout *pango_cairo_layout = pango_cairo_create_layout (cr);
  pango_layout_set_font_description (pango_cairo_layout, desc);
  pango_cairo_context_set_resolution (pango_layout_get_context 
(pango_cairo_layout), dpi);
  cairo_font_options_t *options = cairo_font_options_create ();
  cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
  cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
  pango_cairo_context_set_font_options (pango_layout_get_context 
(pango_cairo_layout), options);
  cairo_font_options_destroy (options);
  pango_layout_set_text (pango_cairo_layout,
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog 
 the quick brown fox jumped over the lazy dog, 
-1);
  pango_layout_set_width (pango_cairo_layout, 100*PANGO_SCALE);
  cairo_move_to (cr, 0, 0);
  pango_cairo_show_layout (cr, pango_cairo_layout);
  g_object_unref (pango_cairo_layout);
  pango_font_description_free (desc);

  cairo_select_font_face (cr, Sans, CAIRO_FONT_SLANT_NORMAL,
  CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size (cr, 12.0);   /* size em in mm */
  cairo_move_to(cr, 0., 120.);
  cairo_show_text(cr, m Hello World! Printing...);
  cairo_move_to(cr, 0., 120.);
  cairo_line_to(cr, 12., 120.);
  cairo_set_line_width (cr, .2);
  cairo_stroke (cr);

  cairo_show_page (cr);
}

static void
print_page (GtkPrintOperation *operation, GtkPrintContext *context,
gint page_nr, gpointer user_data)
{
  g_debug(Print dpi = %f, scale = %f., gtk_print_context_get_dpi_y 
(context), gtk_print_context_get_dpi_y (context)/25.4);
  cairo_t *cr = gtk_print_context_get_cairo_context (context);

  cairo_scale (cr,
   gtk_print_context_get_dpi_x (context)/25.4,
   gtk_print_context_get_dpi_y (context)/25.4);
  draw_page (cr);
}


void YGTK_page_setup()
{
  if (settings == NULL)
settings = gtk_print_settings_new ();

  GtkPageSetup *new_page_setup =
  gtk_print_run_page_setup_dialog (GTK_WINDOW (window), page_setup, 
settings);

  if (page_setup)
g_object_unref (page_setup);

  page_setup = new_page_setup;
  gtk_widget_queue_draw (window);
}


void YGTK_print_dialog()
{
  GtkPrintOperation *print;
  GtkPrintOperationResult result;
  GError *error;

  print = gtk_print_operation_new ();

  if (settings != NULL)
gtk_print_operation_set_print_settings (print, settings);
  g_return_if_fail (page_setup != NULL);
  gtk_print_operation_set_default_page_setup (print, page_setup

Re: GTK+ 2.12.6 and wimp

2008-02-11 Thread Bastiaan Veelo
Tor Lillqvist wrote:
 Did you expect the wimp theme to automatically get used?

Yes, I have previously used an installer to get the runtime for 2.10, 
which probably took care of it.

 You need to either put the line

 gtk-theme-name = MS-Windows

 in your gtkrc file

Thanks, this works. Should I have read this somewhere? Otherwise this 
info may be worth having on http://www.gtk.org/download-windows.html.

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


GTK+ 2.12.6 and wimp

2008-02-10 Thread Bastiaan Veelo
Hi,

I installed version 2.12.6 on Windows according to 
http://www.gtk.org/download-windows.html, but I cannot get the wimp 
theme enigne to load -- all is in the default GTK theme. The archives 
have been unpacked in the same directory, and the bin subdirectory has 
been added to the PATH environment variable.

Oddly, libwimp.dll is in lib/gtk-2.0/2.10.0/engines. Adding that 
directory to PATH does not help, neither does renaming 2.10.0 to 2.12.6.

Have I overseen a configuration step, or is there something wrong with 
the current windows build?

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


Re: GTK equivalent to exit() function in callback

2008-01-14 Thread Bastiaan Veelo
Have a look at the concept proposed in the last paragraph of 
http://lists.ximian.com/pipermail/gtk-sharp-list/2004-November/005148.html

Good luck,
Bastiaan.

[EMAIL PROTECTED] wrote:
 Hi all,


 How do I exit from callback function at my discretion[instead of quitting
 by reaching end of callback function].

 Basically, I want to validate data entered in window elements, and if data
 entered is invalid, I want to exit from the call back function.


 Vijay


   
 

 *
 DISCLAIMER 
 This e-mail and any files transmitted with it are for the sole use of the 
 intended recipient(s) and may contain confidential and privileged 
 information. 
 Any use,distribution,copying or disclosure by any other person is strictly 
 prohibited. If you have received this transmission in error please notify 
 SETS immediately either by replying to this e-mail or by telephone 
 +91-44-28205655 and then delete this e-mail. The sender does not accept any 
 responsibility for any damage which you sustain as a result of software 
 viruses or malicious programs. You should therefore scan attachments (if any) 
 prior to opening them. 
 





   
 

 ___
 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


Re: How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-09 Thread Bastiaan Veelo
Kristian Rietveld wrote:
 On Mon, Oct 08, 2007 at 03:53:29PM +0200, Bastiaan Veelo wrote:
   
 Something like this seems to work for me:

   button = gtk_button_new_with_label (...);
   style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (button),
  *.GtkTreeView.GtkButton,
  NULL,
  G_OBJECT_TYPE (button));
   gtk_widget_set_style (button, style);
   
snip
 I guess I need to trick the theme engine into thinking that it is 
 drawing a GtkTreeView button. Is there a way to do that? If the method 
 would be engine-dependent, I need it to work on MS Windows.
 

 That is exactly what the code above tries to achieve.
snip

The reason why this is not going to work (for the windows theme at 
least, GTK+ 2.10) is a hard-coded check on the type of widget-parent in 
draw_box() on line 1929 of msw_style.c:

if (GTK_IS_TREE_VIEW (widget-parent)
|| GTK_IS_CLIST (widget-parent))
{
if (xp_theme_draw
(window, XP_THEME_ELEMENT_LIST_HEADER, style, x, y,
 width, height, state_type, area))
return;


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


Re: How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-09 Thread Bastiaan Veelo
Bastiaan Veelo wrote:
 The reason why this is not going to work (for the windows theme at
 least, GTK+ 2.10) is a hard-coded check on the type of widget-parent in 
 draw_box() on line 1929 of msw_style.c:
   

So I faked the parent widget through some evil hacking in the expose 
function below. It works, for now.


#include gtk/gtk.h

G_BEGIN_DECLS

#define GTK_TYPE_HEADER (gtk_header_get_type ())
#define GTK_HEADER(obj) (G_TYPE_CHECK_INSTANCE_CAST 
((obj), GTK_TYPE_HEADER, GtkMenuSheet))
#define GTK_HEADER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST ((klass, 
GTK_TYPE_HEADER, GtkMenuSheetClass))
#define GTK_IS_HEADER(obj)  (G_TYPE_CHECK_INSTANCE_TYPE 
((obj), GTK_TYPE_HEADER))
#define GTK_IS_HEADER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE 
((klass), GTK_TYPE_HEADER))
#define GTK_HEADER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS 
((obj), GTK_TYPE_HEADER, GtkMenuSheetClass))

typedef struct _GtkHeader   GtkHeader;
typedef struct _GtkHeaderClass  GtkHeaderClass;

struct _GtkHeader
{
  GtkButton parent;
};

struct _GtkHeaderClass
{
  GtkButtonClass parent_class;
};

G_END_DECLS

GTypegtk_header_get_type (void) G_GNUC_CONST;
GtkWidget   *gtk_header_sheet_new();
static gboolean  gtk_header_expose   (GtkWidget  
*widget,
  GdkEventExpose 
*event);

static void
gtk_header_class_init (GtkHeaderClass *class)
{
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
  widget_class-expose_event = gtk_header_expose;
}

static void
gtk_header_init (GtkHeader *header)
{
}

/* GType Methods */

G_DEFINE_TYPE (GtkHeader, gtk_header, GTK_TYPE_BUTTON)

GType
gtk_header_type ()
{
  static GType header_type = 0;

  if (!header_type)
  {
static const GTypeInfo header_info =
{
  sizeof (GtkHeaderClass),
  NULL, /* base_init */
  NULL, /* base_finalize */
  (GClassInitFunc) gtk_header_class_init,
  NULL, /* class_finalize */
  NULL, /* class_data */
  sizeof (GtkHeader),
  0,/* n_preallocs */
  (GInstanceInitFunc) gtk_header_init,
};

header_type = g_type_register_static (GTK_TYPE_BUTTON,
  GtkHeader,
  header_info,
  0);
  }
  return header_type;
}

static gboolean
gtk_header_expose (GtkWidget  *widget,
   GdkEventExpose *event)
{
  static GtkWidget *treeview = NULL;
  if (!treeview) treeview = gtk_tree_view_new();

  /* Trick draw_box() in msw_style.c on line 1929 into thinking that our 
parent
 is a GtkTreeView. This works on MS Windows and GTK+ 2.10.6, but it may
 fail miserably when used with other themes or other versions of 
GTK+. */
  GtkWidget *real_parent = widget-parent;
  widget-parent = treeview;
  (* GTK_WIDGET_CLASS (gtk_header_parent_class)-expose_event) (widget, 
event);
  widget-parent = real_parent;

  return FALSE;
}

GtkWidget*
gtk_header_new (void)
{
  return g_object_new (GTK_TYPE_HEADER, NULL);
}

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

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, destroy,
G_CALLBACK (gtk_widget_destroyed), window);

  GtkWidget *header = gtk_header_new();
  gtk_button_set_label (GTK_BUTTON (header), Header);
  /* Not sure whether the folowwing is necessary. */
  GtkStyle *style = gtk_rc_get_style_by_paths (gtk_widget_get_settings 
(header),
   NULL,
   *.GtkTreeView.GtkButton,
   GTK_TYPE_BUTTON);
  gtk_widget_set_style (header, style);
  gtk_container_add (GTK_CONTAINER (window), header);

  gtk_widget_show_all(window);
  gtk_main ();

  return 0;
}


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


How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-08 Thread Bastiaan Veelo
Kristian Rietveld wrote:
 Hi,

 On Sun, Oct 07, 2007 at 12:35:01PM +0200, Bastiaan Veelo wrote:
   
 I am a style newbie. I want some of the buttons in my widget to look 
 like the column title buttons in a treeview. How do I do that?
 

 Something like this seems to work for me:

   button = gtk_button_new_with_label (...);
   style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (button),
  *.GtkTreeView.GtkButton,
  NULL,
  G_OBJECT_TYPE (button));
   gtk_widget_set_style (button, style);

   

Thank you for replying. However, for me the above has no visible effect. 
Now I understand that a GtkStyle is just about colors and similar 
settings, which only partly determine the looks of a widget. In my case 
I suspect that a GtkTreeView.GtkButton has the same GtkStyle settings as 
ordinary buttons, which is why I see no change.

What I want is that a button of my choice is rendered exactly like the 
title button in a treeview. I rephrased the subject accordingly.

I recently discovered that there is something called a theme engine, and 
I guess I need to trick the theme engine into thinking that it is 
drawing a GtkTreeView button. Is there a way to do that? If the method 
would be engine-dependent, I need it to work on MS Windows.


Thanks,
Bastiaan.

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


Re: How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-08 Thread Bastiaan Veelo
Kristian Rietveld wrote:
 On Mon, Oct 08, 2007 at 03:53:29PM +0200, Bastiaan Veelo wrote:
   
 Something like this seems to work for me:

   button = gtk_button_new_with_label (...);
   style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (button),
  *.GtkTreeView.GtkButton,
  NULL,
  G_OBJECT_TYPE (button));
   gtk_widget_set_style (button, style);

   
   
 Thank you for replying. However, for me the above has no visible effect. 
 Now I understand that a GtkStyle is just about colors and similar 
 settings, which only partly determine the looks of a widget. In my case 
 I suspect that a GtkTreeView.GtkButton has the same GtkStyle settings as 
 ordinary buttons, which is why I see no change.
 

 By default it does have the same settings, but in multiple themes it
 does not.

   
 I recently discovered that there is something called a theme engine, and 
 I guess I need to trick the theme engine into thinking that it is 
 drawing a GtkTreeView button. Is there a way to do that? If the method 
 would be engine-dependent, I need it to work on MS Windows.
 

 That is exactly what the code above tries to achieve.  I briefly looked
 at the Windows theme source code and figured that it does things a little
 different than the theme engine I first looked at.  Does using:

   style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (button),
  *.GtkTreeView.GtkButton,
  *.GtkTreeView.GtkButton,
  G_OBJECT_TYPE (button));

 instead of the call to gtk_rc_get_style_by_paths() posted earlier have
 any effect?
   

No, it does not. Could it be that the style is overwritten as per 
http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-widget-set-style?

Bastiaan.

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


Re: How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-08 Thread Bastiaan Veelo
I looked at modules/engines/ms-windows/msw_style.c, line 855, and tried 
the following, without succes:

  gchar* class_path = NULL;
  gtk_widget_class_path(button, NULL, class_path, NULL);

  gchar buf[1024];
  g_snprintf (buf, sizeof(buf),
widget_class \%s\ style \msw-header-button\\n,
class_path );
  gtk_rc_parse_string (buf);


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


Re: How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-08 Thread Bastiaan Veelo

Hi,

I have done some more experimenting with styles, attached, and my 
confusion has only grown bigger. See comments in the source. I still 
cannot get an ordinary button to look like a tree view title...


Should I go ask on gtk-devel?

Regards,
Bastiaan.

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

Re: How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-08 Thread Bastiaan Veelo

One more try with attachments.

Bastiaan Veelo wrote:
I have done some more experimenting with styles, attached, and my 
confusion has only grown bigger. See comments in the source. I still 
cannot get an ordinary button to look like a tree view title...


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

Re: How to make a button look like a treeview column title? [Was: How to use the treeview column title style for a button?]

2007-10-08 Thread Bastiaan Veelo
#include gtk/gtk.h

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

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, destroy,
G_CALLBACK (gtk_widget_destroyed), window);

  GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
  GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
  GtkTreeViewColumn *column0 =
  gtk_tree_view_column_new_with_attributes (TreeViewButton,
renderer,
text,
0,
NULL);
  GtkWidget *treeview = gtk_tree_view_new_with_model 
(GTK_TREE_MODEL(store));
  gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column0);
  gtk_box_pack_start_defaults (GTK_BOX (vbox), treeview);

  GtkWidget *button = gtk_button_new_with_label( Ordinary button );
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), button );

  /* Almost the same as ordinary button. Under Windows the focus frame 
is few pixels
   narrower than on an ordinary button. Under Kubuntu the button is 
slightly broader
   than an ordinary button but has no prelight. Anyway it does not look 
like a
   TreeView button at all. */
  GtkWidget *title1 = gtk_button_new_with_label( style by path 
*.GtkTreeView.GtkButton );
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), title1 );
  GtkStyle *style = gtk_rc_get_style_by_paths (gtk_widget_get_settings 
(title1),
   *.GtkTreeView.GtkButton,
   *.GtkTreeView.GtkButton,
   G_OBJECT_TYPE (title1));
  gtk_widget_set_style (title1, style);

  /* Set to its own style. This has the surprising effect that the 
button seems
   to fall back to its default GTK style. */
  GtkWidget *title2 = gtk_button_new_with_label( Set to its own style );
  GtkStyle *style2 = gtk_widget_get_style(title2);
  gtk_widget_set_style (title2, style2);
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), title2 );

  /* Copy the style from title1 which we have previously set. This works 
as expected,
   so why did the style on title2 not work? */
  GtkWidget *title2a = gtk_button_new_with_label( Set to style title1 );
  GtkStyle *style2a = gtk_widget_get_style(title1);
  gtk_widget_set_style (title2a, style2a);
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), title2a );

  /* Set the style from a totally different widget. The button seems to 
fall back
   to GTK style, same as when trying to set to its own style. */
  GtkWidget *title3 = gtk_button_new_with_label( Set to window style );
  GtkStyle *style3 = gtk_widget_get_style(window);
  gtk_widget_set_style (title3, style3);
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), title3 );

  /* This works as expected. */
  GtkWidget *title4 = gtk_button_new_with_label( gtk_widget_set_style() 
button );
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), title4 );
  GtkStyle *style4 = gtk_rc_get_style_by_paths (gtk_widget_get_settings 
(title4),
*Button,
*Button,
 G_OBJECT_TYPE (title4));
  gtk_widget_set_style (title4, style4);

  /* Try a path like msw_style.c uses it. This looks exactly as an 
ordinary button. */
  GtkWidget *title5 = gtk_button_new_with_label( style by path 
*Treeview*Button* );
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), title5 );
  GtkStyle *style5 = gtk_rc_get_style_by_paths (gtk_widget_get_settings 
(title5),
*Treeview*Button*,
*Treeview*Button*,
G_OBJECT_TYPE (title5));
  gtk_widget_set_style (title5, style5);

  /* Under Windows this looks like title1. Under Kubuntu it does too, 
but with prelight. */
  GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start_defaults( GTK_BOX( vbox ), hbox );
  GtkWidget *title6 = gtk_button_new_with_label (msw-header-button);
  gtk_box_pack_start_defaults (GTK_BOX( hbox ), title6);
  gchar* class_path = NULL;
  gtk_widget_class_path(title6, NULL, class_path, NULL);
  g_debug(button class path = %s, class_path);
  gchar buf[1024];
  g_snprintf (buf, sizeof(buf),
  widget_class \%s\ style \msw-header-button\\n,
  class_path );
  g_debug(%s, buf);
  gtk_rc_parse_string (buf);

  gtk_widget_show_all(window);
  gtk_main ();

  return 0;
}


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


How to use the treeview column title style for a button?

2007-10-07 Thread Bastiaan Veelo
Hi,

I am a style newbie. I want some of the buttons in my widget to look 
like the column title buttons in a treeview. How do I do that?

Thanks,
Bastiaan.

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


g_object_ref and g_object_unref in widget implementations

2007-10-06 Thread Bastiaan Veelo
Hi,

I am writing my own widget, and while looking at the widgets in GTK I 
notice the following.

If a widget draws on its parent GdkWindow, you generally see

 widget-window = gtk_widget_get_parent_window (widget);
 g_object_ref (widget-window);

But widget-window is not g_object_unref-ed anywhere in the widget 
implementation. Why shouldn't it?


Thanks,
Bastiaan.



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