Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Tomas Carnecky
Dov Grobgeld wrote:
 Hi Lazy (great name),
 
 The way to do it is to set the name of the label through:
 
 gtk_widget_set_name(label, foo);
 
 and then define a style for the name foo, that includes a font
 specification:
 
 gtk_rc_parse_string(style \foo\ {\n
   font = \Serif 32\\n
   }\n
   );
 

Ugh, that's complicated. An easier way is:

GtkLabel *label = gtk_label_new();
gtk_label_set_markup(label, span font_desc=\10.0\This is a
label/span);

See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
how to use the pango markup language.

 
 2008/8/28 Lazy Fox [EMAIL PROTECTED]
 
 I wrote the following statememts to set a GtkLabel's font size.
 But it seems don't work?
 I'm not good at Pango, can anybody help me?

 +---
 | PangoAttrList *pg_attr_list = pango_attr_list_new();
 | PangoAttribute *pg_attr = pango_attr_size_new(10);
 |
 | label = gtk_label_new(This is a label);
 | pango_attr_list_change(pg_attr_list, pg_attr);
 | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);

 +--

 ___
 gtk-list mailing list
 [EMAIL PROTECTED]
 http://mail.gnome.org/mailman/listinfo/gtk-list


 ___
 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 set the font's size of the GtkLabel?

2008-08-28 Thread Tomas Carnecky
Dov Grobgeld wrote:
 Hi Lazy (great name),
 
 The way to do it is to set the name of the label through:
 
 gtk_widget_set_name(label, foo);
 
 and then define a style for the name foo, that includes a font
 specification:
 
 gtk_rc_parse_string(style \foo\ {\n
   font = \Serif 32\\n
   }\n
   );
 

Ugh, that's complicated. An easier way is:

GtkLabel *label = gtk_label_new();
gtk_label_set_markup(label, span font_desc=\10.0\This is a
label/span);

See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
how to use the pango markup language.

 
 2008/8/28 Lazy Fox [EMAIL PROTECTED]
 
 I wrote the following statememts to set a GtkLabel's font size.
 But it seems don't work?
 I'm not good at Pango, can anybody help me?

 +---
 | PangoAttrList *pg_attr_list = pango_attr_list_new();
 | PangoAttribute *pg_attr = pango_attr_size_new(10);
 |
 | label = gtk_label_new(This is a label);
 | pango_attr_list_change(pg_attr_list, pg_attr);
 | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);

 +--

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


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

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


Re: returning a string to d-bus

2008-08-06 Thread Tomas Carnecky

Luka Napotnik wrote:

Hello.

I have a D-BUS listener with a GObject method which should send a string
back to D-BUS. My d-bus listener method is:

gboolean
some_object_get_name(GObject *object, gchar *str, GError **error)
{
str = g_strdup(Hello);
return TRUE;
}

But when the client connect to this d-bus interface and calls the
get_name() method, the method doesn't return the string. I'm guessing
I'm passing the string the wrong way. Please help.


You probably want:

gboolean
some_object_get_name(GObject *object, gchar **str, GError **error)
{
*str = g_strdup(Hello);
return TRUE
}

and call that function this way:

gchar *str = NULL;
if (some_object_get_name(object, str, error) == TRUE)
gprintf(name: %s\n, str);
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Finding a widget in a Glade interface

2008-07-31 Thread Tomas Carnecky

dhk wrote:

Tristan Van Berkom wrote:
On Wed, Jul 30, 2008 at 3:40 PM, Tristan Van Berkom [EMAIL PROTECTED] 
wrote:

for future reference, this could easily have been pulled out
of the docs/header files: glade_xml_get_widget()

type libglade and feel lucky its right there.


oops, I obviously meant in google here...


I should have mentioned that by time I want to call
glade_xml_get_widget() the GladeXML *xml created by xml =
glade_xml_new(filename.glade, NULL, NULL); is out of scope.  If I call
 open the file again to get the widget it has no affect on the running
window.  I need to get the widget from the running window from some
callback.  Any ideas?


Make 'GladeXML *xml' static or otherwise accessible from all parts of 
the sourcecode.


tom

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


Re: Profiler for GTK+

2008-07-21 Thread Tomas Carnecky

Vinod Alat wrote:

Can anyone suggest me a profiler that shows the CPU time used by
functions in code accumulating the time used in the functions that it
calls (from GTK+ or application), which will help determine what
functions of code take the most time to fulfill, I want to see what
functions of GTK+ are slowing down the application and see if I can
optimize that
functions in GTK+ itself.


gprof or oprofile

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


Re: Callback Parameters are Switched

2008-07-21 Thread Tomas Carnecky

dhk wrote:
I'm using glade for a front end which has a button that when clicked 
passes a notebook as the user_data to the callback.


I'm using the gdb debugger to look at the two parameters in the callback 
and they are switched.  The first parameter, the button, is the notebook 
object and the second parameter, the user_data, is the button object. If 
I don't use user_data in Glade the parameter are correct, the first is 
the button and the second is NULL.


Why is this happening?


http://library.gnome.org/devel/gobject/stable/gobject-Signals.html#g-signal-connect-swapped

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


Re: Callback Parameters are Switched

2008-07-21 Thread Tomas Carnecky

dhk wrote:

Tomas Carnecky wrote:

dhk wrote:
I'm using glade for a front end which has a button that when clicked 
passes a notebook as the user_data to the callback.


I'm using the gdb debugger to look at the two parameters in the 
callback and they are switched.  The first parameter, the button, is 
the notebook object and the second parameter, the user_data, is the 
button object. If I don't use user_data in Glade the parameter are 
correct, the first is the button and the second is NULL.


Why is this happening?


http://library.gnome.org/devel/gobject/stable/gobject-Signals.html#g-signal-connect-swapped 

Ok, I think that explains it, but how was I suppose to know that was 
happening?  . . . and what is the purpose in swapping the parameters? 
Why do that?


There are circumstances where swapping the params is useful. But I have 
no idea why glade does it automatically for you.


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


Re: newbie Question

2008-07-16 Thread Tomas Carnecky
These questions were just examples. Have you read gtk tutorials? Have 
you looked at the gtk examples? Do you know how the glib object system 
(gobject) works? Have you even started writing the code? I doubt it. 
Don't ask the question unless you actually need the answers. When you 
start writing the code other problems will come up, much simpler 
problems. And you'll have to ask much simpler questions. The two 
questions I took as an example are quite advanced ones, you'll need to 
ask those after you have figured out the UI layout and code for it written.


tom

Craig Petty wrote:

how to list available wireless networks and create a custom widget?



--- On Tue, 7/15/08, Tomas Carnecky [EMAIL PROTECTED] wrote:


From: Tomas Carnecky [EMAIL PROTECTED]
Subject: Re: newbie Question
To: [EMAIL PROTECTED]
Cc: gtk-app-devel-list@gnome.org
Date: Tuesday, July 15, 2008, 11:40 AM
Craig Petty wrote:

How would i make a gtk+ for a wireless networking?

First read gtk tutorials. Then compile, run and modify some
gtk samples, 
just so you get into how gtk works. Then you can read the
sourcecode of 
other gtk applications to understand how a 'big'
application is 
structured. And then, if you have a specific question about
for example 
how to create a custom widget, or how to list available
wireless 
networks, you can get back to this mailinglist and ask it.


tom



  
___

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: newbie Question

2008-07-15 Thread Tomas Carnecky

Craig Petty wrote:

How would i make a gtk+ for a wireless networking?


First read gtk tutorials. Then compile, run and modify some gtk samples, 
just so you get into how gtk works. Then you can read the sourcecode of 
other gtk applications to understand how a 'big' application is 
structured. And then, if you have a specific question about for example 
how to create a custom widget, or how to list available wireless 
networks, you can get back to this mailinglist and ask it.


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


Re: font size gtk_*_new_with_label

2008-07-13 Thread Tomas Carnecky

Luis Ariel Lecca wrote:

Hi All ! I will appreciate very much any help :)

I'm using 

gtk_widget_modify_font()  and 


style = gtk_rc_style_new();
pango_font_description_free( style-font_desc );
style-font_desc = pfont;
gtk_widget_modify_style( widget, style );

to change the font size of my labels, but I can't do it on created
buttons with gtk_*_new_with_label() and neither in my statusbar.

I couldn't find any example on the net. I understand that I dont have the 
reference to the labels... , but when gtk refresh the screen needs the 
reference to the labels...

So how to get the reference pointer or directly how to change the font size on 
these objects ?

I have custom labels with my widgets...
Now, I'd rather change as less as possible the Glade code (Glade use 
_with_label in generation code).
I think that would be better using with_label than a custom button (I'm not 
completetly sure about it on gtk).

Could any body give me some help about this problem? I need to solve it



Why don't you use pango markup?

button = gtk_button_new();
label = gtk_label_new();
gtk_label_set_markup(GTK_LABEL(label), span size='large'A/span);
gtk_container_add(GTK_CONTAINER (button), label);

tom


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


Re: [compiz] color management spec

2008-06-10 Thread Tomas Carnecky
Added gtk-devel-list@gnome.org to hear their opinion about this matter. 
For reference, this is what I proposed:

http://lists.freedesktop.org/archives/xorg/2008-May/035772.html

Danny Baumann wrote:

Hi,
 
I strongly dislike supporting subwindow ID/profile tuples. 
The task of 
window and compositing managers is and always has been to 
manage and 
draw _toplevel_ windows, not subwindows. I don't really think that 
adding a subwindow management infrastructure to compositing 
managers 
just for saving some lines of code in the toolkit (and not 
even all of 

them) is an overly good idea.
It's not just for 'saving some lines of code in the toolkit'. 
Color management would require significantly more code in the 
toolkit and would most likely be slower then if it is done in 
the compositing manager.


I was just talking about communicate using subwindow id/profile tuples vs.
communicate using toplevel window region/profile tuples. The former would
save a bit of code in the toolkit, but would complicate compositing managers
significantly; which is why I strongly prefer the latter.


The compositing manager would never actually draw subwindows, just 
merely use them to identify regions.


When using properties on the top level window, the toolkit would have to 
explicitly update those whenever the window is resized. But when using 
subwindows, the toolkit (at least gtk) wouldn't have to do anything 
special. In gtk, each widget that uses a subwindow resizes it when the 
top level window is resized. The compositing manager would just 
subscribe to ConfigureNotify events of the subwindows and be done.


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


Re: glib and Xlib

2008-06-06 Thread Tomas Carnecky
jaafar EL GONNOUNI wrote:
 Hello;
 
 What is *glib *adding that the GTK + compared to *Xlib *?
 
 All what is possible with glib with Xlib is feasible, then why create a new
 library.

 From http://library.gnome.org/devel/glib/stable/glib.html :

GLib is a general-purpose utility library, which provides many useful 
data types, macros, type conversions, string utilities, file utilities, 
a main loop abstraction, and so on. It works on many UNIX-like 
platforms, Windows, OS/2 and BeOS. GLib is released under the GNU 
Library General Public License (GNU LGPL).


 From http://tronche.com/gui/x/xlib/introduction/ :

The X Window System is a network-transparent window system that was 
designed at MIT. X display servers run on computers with either 
monochrome or color bitmap display hardware. The server distributes user 
input to and accepts output requests from various client programs 
located either on the same machine or elsewhere in the network. Xlib is 
a C subroutine library that application programs (clients) use to 
interface with the window system by means of a stream connection. 
Although a client usually runs on the same machine as the X server it is 
talking to, this need not be the case.


I hope you can see the difference.

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


Re: glib and Xlib

2008-06-06 Thread Tomas Carnecky
jaafar EL GONNOUNI wrote:
 Hello;
 
 What is *glib *adding that the GTK + compared to *Xlib *?
 
 All what is possible with glib with Xlib is feasible, then why create a new
 library.

 From http://library.gnome.org/devel/glib/stable/glib.html :

GLib is a general-purpose utility library, which provides many useful 
data types, macros, type conversions, string utilities, file utilities, 
a main loop abstraction, and so on. It works on many UNIX-like 
platforms, Windows, OS/2 and BeOS. GLib is released under the GNU 
Library General Public License (GNU LGPL).


 From http://tronche.com/gui/x/xlib/introduction/ :

The X Window System is a network-transparent window system that was 
designed at MIT. X display servers run on computers with either 
monochrome or color bitmap display hardware. The server distributes user 
input to and accepts output requests from various client programs 
located either on the same machine or elsewhere in the network. Xlib is 
a C subroutine library that application programs (clients) use to 
interface with the window system by means of a stream connection. 
Although a client usually runs on the same machine as the X server it is 
talking to, this need not be the case.


I hope you can see the difference.

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


Re: The core of GTK++

2008-05-29 Thread Tomas Carnecky
jaafar EL GONNOUNI wrote:
 Good morning;
 
 What are the source files that formed the *core *of GTK++ ?

How do you define the core? What belongs to your 'core'?

 
 *According to my research I found the following files :
 
 *  gtkobject.c / gtkobject.h
   gtkwidget.c / gtkwidget.h
   gtkcontainer.c / gtkcontainer.h
   gtkmain.c / gtkmain.h
   gtksignal.c / gtksignal.h
   gtktypeutils.c / gtktypeutils.h
   gtkdata.c / gtkdata.h
 
 Can you confirm this ?

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


Re: The core of GTK++

2008-05-29 Thread Tomas Carnecky
jaafar EL GONNOUNI wrote:
 Good morning;
 
 What are the source files that formed the *core *of GTK++ ?

How do you define the core? What belongs to your 'core'?

 
 *According to my research I found the following files :
 
 *  gtkobject.c / gtkobject.h
   gtkwidget.c / gtkwidget.h
   gtkcontainer.c / gtkcontainer.h
   gtkmain.c / gtkmain.h
   gtksignal.c / gtksignal.h
   gtktypeutils.c / gtktypeutils.h
   gtkdata.c / gtkdata.h
 
 Can you confirm this ?

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


Re: GtkContainer problems

2008-04-29 Thread Tomas Carnecky
AlannY wrote:
 Hello.
 
 I'm writing a custom widget. It's inherits from GtkContainer. So:
 
 typedef struct _MyWidgetMyWidget;
 typedef struct _MyWidgetClass   MyWidgetClass;
 
 struct _MyWidget
 {
GtkContainer parent;
 };
 
 struct _MyWidgetClass
 {
GtkContainerClass parent_class;
 };
 
 I'm wrote a small test program:
 
 [...]
 mywidget = mywidget_new ();

Where is this function defined? How does that function look? Post _all_ 
code for MyWidget and not just the parts you think are important.

 gtk_container_add (GTK_CONTAINER (mywidget), button);
 [...]
 
 But I got a message:
 
 Gtk-CRITICAL **: gtk_container_add: assertion `GTK_IS_CONTAINER 
 (container)' failed
 
 Why?

tom


-- 
So Long, and Thanks for All the Fish
___
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 put widget in CUSTOM GtkContainer

2008-04-29 Thread Tomas Carnecky
AlannY wrote:
 Hi there, my name is Alan and I have some troubles with GtkContainer.
 
 It's about 2 days, I already have spent trying to solve it, but I (i 
 guess) can't.
 
 I'm writing a program, which looks like:
 +-+
 | Main Window (GtkWindow) |
 | +-+ |
 | | My custom widget| |
 | | +-+ | |
 | | | GtkButton   | | |
 | | +-+ | |
 | +-+ |
 +-+
 
 I need some approach to place a GtkButton in my custom widget. I found 
 (from GTK+ sources) that GtkTreeView, GtkNotebook (and others) inherits 
 from GtkContainer . So, I decide to inherit my widget not from 
 GtkWidget, but from GtkContainer.
 
 typedef struct _GridGrid;
 typedef struct _GridClass   GridClass;
 
 struct _Grid
 {
GtkContainer parent;
 };
 
 struct _GridClass
 {
GtkContainerClass parent_class;
 };
 
 And my _get_type function looks like:
 
 GtkType
 grid_get_type ()
 {
static GtkType grid_type = 0;
 
if (!grid_type)
  {
const GTypeInfo object_info =
{
   sizeof (GtkContainerClass),
   NULL,
  NULL,
   (GClassInitFunc) grid_class_init,

That still isn't the whole code! What does grid_class_init() do? Attach 
both the whole grid header and source file to the email.

   NULL,
   NULL,
   sizeof (Grid),
   0,
   (GInstanceInitFunc) grid_init,
   NULL,
};
 
grid_type = g_type_register_static (GTK_TYPE_CONTAINER, 
 g_intern_static_string (Grid), object_info, 0);
  }
 
return grid_type;
 }
 
 The main feature of this function is GTK_TYPE_CONTAINER ;-) You see ;-)
 
 Next in my program, I'm creating my widget (grid) with that:
 
 [...]
 grid = grid_new ();
 gtk_container_add (GTK_CONTAINER (window), grid);
 [...]
 
 So, my problem starts here: at _new() function. I want to create 
 GtkButton and place it in my widget.
 
 GtkWidget*
 grid_new ()
 {
Grid *grid;
 
grid = g_object_new (grid_get_type (), NULL);
 
button = gtk_button_new_with_label (Test);
gtk_widget_set_parent (button, GTK_WIDGET (grid));
gtk_widget_show (button);
 
return GTK_WIDGET (grid);
 }
 
 Everything right and works without errors ;-) But nothing happens. I 
 can't see a GtkButton ;-)
 
 How to solve it? I need some way for draw (expose) GtkButton in my 
 custom widget ;-) How to do it?
 
 P.S. I extremely think, that I just forgot something. But there are no 
 tutorials about it ;-) Information vacuum, so I decide to ask in 
 mailing-lists.
 P.P.S. Only information about custom widget creation is a GTK sources, 
 but (even with it) I can't solve my problem. ;-)
 P.P.P.S. Also, I really want to understand how GtkBox works ;-)

And stop creating new threads... This is your third thread in 
gtk-app-devel where you ask the same question.

tom

___
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 put widget in CUSTOM GtkContainer

2008-04-29 Thread Tomas Carnecky
AlannY wrote:
 Tomas Carnecky wrote:
 AlannY wrote:
 That still isn't the whole code! What does grid_class_init() do? Attach 
 both the whole grid header and source file to the email.
 
 /* ** */
 
 static void
 grid_class_init (GridClass *class)
 {
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
 
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
 
parent_class = gtk_type_class (gtk_widget_get_type ());
 
object_class-destroy = grid_destroy;
 
widget_class-realize = grid_realize;
widget_class-expose_event = grid_expose;

here you have to set GtkContainerClass-add, remove, forall and 
child_type. See 
http://svn.gnome.org/viewvc/gtk%2B/trunk/gtk/gtkbin.c?revision=19491view=markup
 
as an example of a widget that derives from GtkContainer.

 }
 
 /* ** */
 static void
 grid_init (Grid *grid)
 {
 }
 
 /* ** */
 static void
 grid_realize (GtkWidget *widget)
 {
Grid *grid;
GdkWindowAttr attributes;
gint attributes_mask;
 
g_return_if_fail (widget != NULL);
g_return_if_fail (IS_GRID (widget));
 
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
grid = GRID (widget);
 
attributes.x = widget-allocation.x;
attributes.y = widget-allocation.y;
attributes.width = widget-allocation.width;
attributes.height = widget-allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = gtk_widget_get_events (widget) | 
 GDK_EXPOSURE_MASK;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
 
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget-window = gdk_window_new (widget-parent-window, attributes, 
 attributes_mask);
 
widget-style = gtk_style_attach (widget-style, widget-window);
 
gdk_window_set_user_data (widget-window, widget);
 
gtk_style_set_background (widget-style, widget-window, 
 GTK_STATE_ACTIVE);
 }
 
 /* ** */
 static gboolean
 grid_expose (GtkWidget *widget,
   GdkEventExpose *event)
 {
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (IS_GRID (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
 
if (event-count  0)
  return FALSE;
 
return FALSE;
 }
 
 /* ** */
 static void
 grid_destroy (GtkObject *object)
 {
g_return_if_fail (object != NULL);
g_return_if_fail (IS_GRID (object));
 
if (GTK_OBJECT_CLASS (parent_class)-destroy)
  (* GTK_OBJECT_CLASS (parent_class)-destroy) (object);
 }
 
 /* ** */
 
 That's all I have ;-)
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 


-- 
So Long, and Thanks for All the Fish
___
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 put widget in CUSTOM GtkContainer

2008-04-29 Thread Tomas Carnecky
AlannY wrote:
  Tomas Carnecky wrote:
  here you have to set GtkContainerClass-add, remove, forall and
  child_type. See
  
http://svn.gnome.org/viewvc/gtk%2B/trunk/gtk/gtkbin.c?revision=19491view=markup
 

  as an example of a widget that derives from GtkContainer.
 
  Since now, Yes ;-) I have ;-) But nothing changes ;-)
 

It's mighty difficult to help you. You still haven't showed us something 
that compiles, something we could run and test ourselves...

tom
___
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 put widget in CUSTOM GtkContainer

2008-04-29 Thread Tomas Carnecky
AlannY wrote:
 Hi there, my name is Alan and I have some troubles with GtkContainer.
 
 It's about 2 days, I already have spent trying to solve it, but I (i 
 guess) can't.
 
 I'm writing a program, which looks like:
 +-+
 | Main Window (GtkWindow) |
 | +-+ |
 | | My custom widget| |
 | | +-+ | |
 | | | GtkButton   | | |
 | | +-+ | |
 | +-+ |
 +-+
 
 I need some approach to place a GtkButton in my custom widget. I found 
 (from GTK+ sources) that GtkTreeView, GtkNotebook (and others) inherits 
 from GtkContainer . So, I decide to inherit my widget not from 
 GtkWidget, but from GtkContainer.
 
 typedef struct _GridGrid;
 typedef struct _GridClass   GridClass;
 
 struct _Grid
 {
GtkContainer parent;
 };
 
 struct _GridClass
 {
GtkContainerClass parent_class;
 };
 
 And my _get_type function looks like:
 
 GtkType
 grid_get_type ()
 {
static GtkType grid_type = 0;
 
if (!grid_type)
  {
const GTypeInfo object_info =
{
   sizeof (GtkContainerClass),
   NULL,
  NULL,
   (GClassInitFunc) grid_class_init,

That still isn't the whole code! What does grid_class_init() do? Attach 
both the whole grid header and source file to the email.

   NULL,
   NULL,
   sizeof (Grid),
   0,
   (GInstanceInitFunc) grid_init,
   NULL,
};
 
grid_type = g_type_register_static (GTK_TYPE_CONTAINER, 
 g_intern_static_string (Grid), object_info, 0);
  }
 
return grid_type;
 }
 
 The main feature of this function is GTK_TYPE_CONTAINER ;-) You see ;-)
 
 Next in my program, I'm creating my widget (grid) with that:
 
 [...]
 grid = grid_new ();
 gtk_container_add (GTK_CONTAINER (window), grid);
 [...]
 
 So, my problem starts here: at _new() function. I want to create 
 GtkButton and place it in my widget.
 
 GtkWidget*
 grid_new ()
 {
Grid *grid;
 
grid = g_object_new (grid_get_type (), NULL);
 
button = gtk_button_new_with_label (Test);
gtk_widget_set_parent (button, GTK_WIDGET (grid));
gtk_widget_show (button);
 
return GTK_WIDGET (grid);
 }
 
 Everything right and works without errors ;-) But nothing happens. I 
 can't see a GtkButton ;-)
 
 How to solve it? I need some way for draw (expose) GtkButton in my 
 custom widget ;-) How to do it?
 
 P.S. I extremely think, that I just forgot something. But there are no 
 tutorials about it ;-) Information vacuum, so I decide to ask in 
 mailing-lists.
 P.P.S. Only information about custom widget creation is a GTK sources, 
 but (even with it) I can't solve my problem. ;-)
 P.P.P.S. Also, I really want to understand how GtkBox works ;-)

And stop creating new threads... This is your third thread in 
gtk-app-devel where you ask the same question.

tom

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


Re: Simple Questions.

2008-04-19 Thread Tomas Carnecky
Schumi Imor wrote:
 I'm thinking of using GTK+ for one of my projects and I'm really impressed
 with the level of support and example code out there. But what I haven't
 been able to find is how to create an application without a frame (no name,
 no close, no maximize, no edges). Any help or example code would be
 appreciated...

http://library.gnome.org/devel/gtk/stable/GtkWindow.html#gtk-window-set-decorated

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


Re: How can I find out what is the gtk development version?

2008-04-10 Thread Tomas Carnecky
ying lcs wrote:
 On Thu, Apr 10, 2008 at 11:12 AM, Kevin DeKorte [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1


  ying lcs wrote:
  | Hi,
  |
  | How can I find out what is the gtk development version that I am using
  on linux?


  ~ pkg-config --modversion gtk+-2.0


  Should give you the version

  Kevin

 
 Thanks you. I just did it, but I get:
 
 # pkg-config --modversion gtk+2.0
 Package gtk+2.0 was not found in the pkg-config search path.
 Perhaps you should add the directory containing `gtk+2.0.pc'
 to the PKG_CONFIG_PATH environment variable
 No package 'gtk+2.0' found
 
 But I am running gnome, so I must have gtk+.
 
 Is that a setting issue?

Do you have the -devel package installed?

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


Re: How can I find out what is the gtk development version?

2008-04-10 Thread Tomas Carnecky
ying lcs wrote:
 On Thu, Apr 10, 2008 at 11:12 AM, Kevin DeKorte [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1


  ying lcs wrote:
  | Hi,
  |
  | How can I find out what is the gtk development version that I am using
  on linux?


  ~ pkg-config --modversion gtk+-2.0


  Should give you the version

  Kevin

 
 Thanks you. I just did it, but I get:
 
 # pkg-config --modversion gtk+2.0
 Package gtk+2.0 was not found in the pkg-config search path.
 Perhaps you should add the directory containing `gtk+2.0.pc'
 to the PKG_CONFIG_PATH environment variable
 No package 'gtk+2.0' found
 
 But I am running gnome, so I must have gtk+.
 
 Is that a setting issue?
 

err.. try this:

pkg-config --modversion gtk+-2.0

(it's $package-$version and the package is 'gtk+' and version '2.0', 
hence you get 'gtk+-2.0', the '+-' can be a bit confusing)

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


Re: GTK app to change pic on click

2008-03-18 Thread Tomas Carnecky
Midhun A wrote:
 Hi All,
 
   I am very new to GTK+ (started out yesterday). I am writing a simple
 application which will show pictures one by one on button click.
 Although I am able to get my first picture, the picture does not
 change on click of the button (next or previous). The full code is as
 below.
 
 #include stdio.h
 #include gtk/gtk.h
 #include string.h
 #include unistd.h
 #include /usr/include/stdio.h
 #include glib.h
 
 GtkWidget *image2;
 GtkWidget *window;
 GtkWidget *vbox;
 GtkWidget *prev_button, *next_button;
 
 
 
 gchar *files[6] =
 {
 /home/pics/1.jpg,
 /home/pics/2.jpg,
 /home/pics/3.jpg,
 /home/pics/4.jpg,
 /home/pics/5.jpg,
 /home/pics/6.jpg
 };
 
 typedef struct{
 gint data;
 } data;
 
 void prev_callback (GtkWidget *widget, data *v )
 {
   gint cnt = v-data;
   if (cnt == 0)
   cnt = 5;
   else
   cnt = cnt - 1;
   
   image2 = gtk_image_new_from_file (files[cnt]);
 }

This callback only creates the new image, it doesn't display it in the 
window. You seem to lack basic C understanding, especially about pointers.

To replace the current image, you have to remove the image widget from 
the vbox and replace it with the new image. Like this:

 void next_callback (GtkWidget *widget, data *v)
 {
   int cnt = v-data;
   if (cnt == 5)
   cnt = 0;
   else
   cnt = cnt + 1;
   
gtk_container_remove(GTK_CONTAINER(vbox), image2);
   image2 = gtk_image_new_from_file (files[cnt]);
gtk_container_add(GTK_CONTAINER(vbox), image2);
 }
 
 
 int main (int argc, char *argv[])
 {
 
   data *w = g_slice_new(data);
   w-data = 0;
 
   gtk_init(argc,argv);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_maximize (window);
   
   vbox = gtk_vbox_new(FALSE, 1);
 
   image2 = gtk_image_new_from_file (files[w-data]);
   gtk_container_add(GTK_CONTAINER(vbox), image2);
   
   prev_button = gtk_button_new_with_mnemonic (Previous);
   next_button = gtk_button_new_with_mnemonic (Next);
 
   gtk_widget_set_name(prev_button,prev_button);
   gtk_widget_set_name(next_button,next_button); 
 
   gtk_container_add(GTK_CONTAINER(vbox), prev_button);
   gtk_container_add(GTK_CONTAINER(vbox), next_button);
   gtk_container_add(GTK_CONTAINER(window), vbox); 
 
   g_signal_connect (G_OBJECT (prev_button), clicked, G_CALLBACK
 (prev_callback),(gpointer)w);
   g_signal_connect (G_OBJECT (next_button), clicked, G_CALLBACK
 (next_callback),(gpointer)w);
 
   gtk_widget_show (image2);
   gtk_widget_show (prev_button);
   gtk_widget_show (next_button);  
   gtk_widget_show (vbox); 
   gtk_widget_show (window);
   
   gtk_main();
   return 0;
 }
 
 
 This is very primitive code to test the functionality.  Whats wrong
 with the code? I would like to see the previous picture on click of
 previous button and the next picture on click of next button.
 

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


Re: Does libX11 use shared memory between several clients?

2008-01-29 Thread Tomas Carnecky
Bin Chen wrote:
 Currently I am looking at libX11's source code, I am curios many
 libX11 doesn't send the message to the server but only modify some
 structure in the local memory, such as:

This is the gtk-app-devel list, not the place where you'd discuss libX11 
issues! You'll have more luck asking in [EMAIL PROTECTED]

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


widgets in cell renderer

2008-01-25 Thread Tomas Carnecky
I'm working on a fairly complex cell renderer, with text, progress bars, 
buttons, etc. Since th cell renderer is not a widget, but only a simple 
renderer, I have to paint it all by myself, using gtk_paint_box(), 
gdk_draw_pixbuf(), gtk_paint_layout() etc. Now it's getting ugly and I 
thought about creating a normal GtkButton and then call the _paint() 
function to paint it into the cell renderer. But that is not easy since 
no _paint function is exposed through the official API. So I though 
about calling klass-expose_event() but that leads to problems and/or 
crashes. I really don't want to duplicate button and other paint code 
inside my cell renderer, is there really no way of using the standard 
gtk widgets and draw them inside a cell area?

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


Re: XF86AudioNext

2008-01-03 Thread Tomas Carnecky
Kevin DeKorte wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Hi,
 
 I'm trying to capture the keypress when a user hits a key like XF86AudioNext
 
 I have a keyboard handler for my window and I get events for keys like
 F10 and 'a' and the Ctrl-x keys, but keys like XF86AudioNext don't seem
 to be passed at all to my keyboard handler.
 
 Is there something special I need to do in order to capture that keypress?
 

Maybe gnome intercepts it, look into gnome-control-center - Personal - 
Keyboard Shortcuts. That is done so you can always press the key, no 
matter which app has focus, and gnome automatically reroutes the key to 
the currently active sound player (sonata in my case, not sure whether 
rhythmbox or amarok supports that).

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


Re: gtk.image

2007-12-25 Thread Tomas Carnecky
brad smith wrote:
 Hello everyone,
 
 I am using gtk.Image() and filling it with set_from_file with a random

I assume you're using the python bindings..

 image in a directory. I am trying to use gtk.get_image() to get the
 name of the image currently being displayed but I get:
 gImage = self.rImage.get_image()
 ValueError: image should be a GdkImage or empty
 
 There is a image being displayed when I try to get image name.
 Thanks for your time,

RTFM, especially what get_image() returns:
http://www.pygtk.org/pygtk2reference/class-gtkimage.html#method-gtkimage--get-image

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


Re: gtk.image

2007-12-25 Thread Tomas Carnecky
brad smith wrote:
 thanks for the reply, I tried everything I can think of, but still get
 the error.

Your problem is that get_image() does _not_ return the filename, but the 
gdk pixbuf for the image - as described in the pygtk reference. So if 
you want to get the filename, you have to use another function.

 On Dec 25, 2007 11:33 AM, Tomas Carnecky [EMAIL PROTECTED] wrote:
 brad smith wrote:
 Hello everyone,

 I am using gtk.Image() and filling it with set_from_file with a random
 I assume you're using the python bindings..

 image in a directory. I am trying to use gtk.get_image() to get the
 name of the image currently being displayed but I get:
 gImage = self.rImage.get_image()
 ValueError: image should be a GdkImage or empty

 There is a image being displayed when I try to get image name.
 Thanks for your time,
 RTFM, especially what get_image() returns:
 http://www.pygtk.org/pygtk2reference/class-gtkimage.html#method-gtkimage--get-image


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


Re: gtk.image

2007-12-25 Thread Tomas Carnecky
brad smith wrote:
 ok, thanks:) Any ideas on that?
 Happy Holidays

So you did not RTFM, eh? I suggest to look there from time to time, it 
really helps.

Sorry, no, I have no idea. But after roughly reading the gtk.Image class 
reference, I don't see any way of extracting the filename, because it 
apparently isn't saved in gtk.Image. That's probably because the image 
may also come from other sources such as memory or is copied over from a 
gdk drawable etc. The image isn't always tied to a particular file. 
You'd have to do that yourself.

I'm not a pygtk expert, but that's what I could find out from the link I 
gave you and my experience with gtk+.

 
 On Dec 25, 2007 1:03 PM, Tomas Carnecky [EMAIL PROTECTED] wrote:
 brad smith wrote:
 thanks for the reply, I tried everything I can think of, but still get
 the error.
 Your problem is that get_image() does _not_ return the filename, but the
 gdk pixbuf for the image - as described in the pygtk reference. So if
 you want to get the filename, you have to use another function.


 On Dec 25, 2007 11:33 AM, Tomas Carnecky [EMAIL PROTECTED] wrote:
 brad smith wrote:
 Hello everyone,

 I am using gtk.Image() and filling it with set_from_file with a random
 I assume you're using the python bindings..

 image in a directory. I am trying to use gtk.get_image() to get the
 name of the image currently being displayed but I get:
 gImage = self.rImage.get_image()
 ValueError: image should be a GdkImage or empty

 There is a image being displayed when I try to get image name.
 Thanks for your time,
 RTFM, especially what get_image() returns:
 http://www.pygtk.org/pygtk2reference/class-gtkimage.html#method-gtkimage--get-image



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


Re: Button Callbacks

2007-12-19 Thread Tomas Carnecky
Vroni wrote:
 Hi guys,
 
 I have this really dumb problem, but I canĀ“t get my head around it. My 
 program should do the following:
 
 - When a button is pressed, a specific playlist[m3u]-file should be 
 opened in the media player.
 
 Sure, the first part is to add a callback for the buttons, but how do I 
 open the file (and with it the media player. It should do the same as a 
 double click on the file would)?
 Is it even possible to do do it this way?

In a terminal, you'd do:
  $ xdg-open /path/to/playlist.m3u

In your callback you'd probably want to use system() or g_spawn_async(), 
see the man pages and
http://www.gtk.org/api/2.6/glib/glib-Spawning-Processes.html

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

Re: [n00b] what's a smooth_draw_box?

2007-12-18 Thread Tomas Carnecky
Daniel Fetchinson wrote:
 Hi list,
 
 I've just started with GTK and been going through the tutorial and
 examples. My first small application is working all right but the
 following (I guess) warning keeps being written to the console:
 
 CRITICAL **: smooth_draw_box: assertion `width = -1'
 
 and strangely enough Google doesn't return any pages for the queries
 
 http://www.google.com/search?q=smooth_draw_box+site%3Agtk.org
 http://www.google.com/search?q=smooth_draw_box+site%3Alibrary.gnome.org
 

Try dropping the 'site:gtk.org' part, you'll get lots of hits.

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


Re: Multi-threaded UI Freezes on GDK Call

2007-12-18 Thread Tomas Carnecky
Michael McCann wrote:
 Michael R. Head wrote:
 On Tue, 2007-12-18 at 17:14 -0500, Michael R. Head wrote:
   
 I assume you meant

 g_threads_init();
 gdk_threads_init();
 gtk_init();
 
 gdk_threads_enter();
 gtk_main();
 gdk_threads_leave();

 right?
 
 Yes, that is correct. :)
 Does your special function take time to do its job? If so, then that
 would be why. For example:

 ...
 while(1) {
 gdk_threads_enter();
 sleep(1)
 gdk_threads_leave();
 sleep(10)
 };
 ...

 you'd freeze your app for a second every 10 seconds.


   
 
 Ahh, ok. How else can I accomplish my goal, then? I need to give GTK the 

Which goal? Describe what your app is supposed to do.

 lock, as I'm calling GDK from another function not in the main GTK loop. 
 I tried leaving out gdk_threads_enter()/leave() in the CPU-intensive 
 function, but X gives me errors.

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


Re: I can't understand the difference output of only a line differ

2007-12-06 Thread Tomas Carnecky
Binary Chen wrote:
 You don't know my situation. I am writing a media player which need to
 copy the decoded bitmap into screen.
 I am using gdk_draw_image to draw a GdkImage to the drawing area.
 g_timeout_add is too slow because it need to update the screen   20
 times/sec.
 So I need to use a FAST blit to screen, which is only possible using
 busy while... but only if the delay is very small using usleep(1), the
 result is - no things on screen.
 Image a situation that a thread is doing decoding and put the result in
 somewhere memory, another thread drawing to GTK+ widget.

You don't seem to understand: You can not use a while loop. At all.
Ever! It simply won't work! Use something else, but _not_ the while loop!

tom

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


Re: C vs C++ for GTK

2007-11-25 Thread Tomas Carnecky
Allin Cottrell wrote:
 One reason for going with C is that the great bulk of free 
 software is in C, including GLib and GTK.  The main exception 
 is Qt, the basis for KDE.  So if you might want to get into KDE 
 programming, maybe learning C++ would be better.

You can use gtk in C++, there's gtkmm which is a thin wrapper on top of
gtk! Many good gtk apps are written in gtk. So actually when using gtk
you are less restricted in your programing language choice than with Qt.

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


Re: C vs C++ for GTK

2007-11-25 Thread Tomas Carnecky
Tomas Carnecky wrote:
 Allin Cottrell wrote:
 One reason for going with C is that the great bulk of free 
 software is in C, including GLib and GTK.  The main exception 
 is Qt, the basis for KDE.  So if you might want to get into KDE 
 programming, maybe learning C++ would be better.
 
 You can use gtk in C++, there's gtkmm which is a thin wrapper on top of
 gtk! Many good gtk apps are written in gtk. So actually when using gtk
 ^^^
 C++

 you are less restricted in your programing language choice than with Qt.
 
 tom

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


Re: C vs C++ for GTK

2007-11-24 Thread Tomas Carnecky
Patrick wrote:
 is C++ to complicated? 
C++ is more complex than C, and thus harder to fully understand.

 Is C going out of date?
No, it's still being used for lots of projects.

 Am I limited with C?
No, there are very few features in C++ that are hard/impossible to
imitate in C, but you usually won't need those for small projects.

What people prefer mostly depends on their taste. I do C, my brother
does C++, I can't say why that is.

Since you worked with python which is object oriented I would imagine
going with C++ will be easier for you during the first weeks.

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


Re: exec application in windows

2007-11-20 Thread Tomas Carnecky
Michael Lamothe wrote:
 
 gboolean ii=g_spawn_comand_line_async  (C:/Archivos de
 programa/GlobalMapper8/global_mapper8.exe,error);
 
 gboolean ii=g_spawn_comand_line_async  (C:/Archivos de
 programa/GlobalMapper8/global_mapper8.exe,error);


The two are exactly the same, C (preprocessor?) concatenates strings.

tom
___
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 get stuff out of a GValue?

2007-11-19 Thread Tomas Carnecky
Dan H wrote:
 OK, I've got something in the form of a GValue (in this case, integer numeric 
 data
 obtained with gtk_container_child_get()), and I'd like to get access to the 
 actual number inside. How is this done? I've looked into GValue's 
 documentation, but all I see is stuff that deals only with GValues and no 
 interface to the outside world of regular C types.
 

http://developer.gimp.org/api/2.0/gobject/gobject-Standard-Parameter-and-Value-Types.html

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


embedding widgets

2007-10-24 Thread Tomas Carnecky
I have created a modification to transmission that changes the look:

http://dbservice.com/ftpdir/tom/screenshot19.png

each line is one custom widget, with a few pango text layouts and the
progressbar in the background. That was quite easy, but how would I go
about embedding for example a whole GtkButton in my custom widget
without having to create a box? Is it somehow possible to access the
GtkButton render() and get_size() functions and use those?

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