getting the allocated size of a widget

2006-05-19 Thread Nick Watts

I'm writing an image viewer application and I want to be able to scale the
image being shown to fit the window, whatever size that may be.  There's
other stuff in the window too so getting just the window size isn't an
option.

What's the easiest/correct way to get the current width and height of a
widget (in this case a scrolled window/viewport)?  Can it be obtained from
the widget's GtkAllocation?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

signals stop working

2006-03-24 Thread Nick Watts
I have an application with several GtkEntry's and a GtkTextView.  I wanted
to put the cut, copy and paste commands in my edit menu with the GTK_STOCK
images and accelerators just for cosmetic value (GtkTextView and
GtkTextEntry support the Ctrl+C, Ctrl+X and Ctrl+V shortcuts natively).  To
do this I have callbacks containin the commands
gtk_text_buffer_cut_clipboard, gtk_text_buffer_copy_clipboard and
gtk_text_buffer_paste_clipboard.

The problem is that since i have accelerators now attached to these
callbacks, the shortcuts like Ctrl+X only work on the main GtkTextView and
won't work on the GtkEntry's when they have focus instead.  How can I tell
the application to simply respond how it normall would and still be able to
use the GTK_STOCK items in my menus (I REALLY don't want to rewrite the menu
code which currently uses the ui-manager commands)?

I thought it would be something like the return FALSE or return TRUE in the
standard delete_event which tells the application to procede with the action
or not.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

clipboards under win32

2006-02-24 Thread Nick Watts
I'm having a little difficulty understanding the concepts behind clipboards
in GTK.

I want to use these functions in a text editing app:

gtk_text_buffer_paste_clipboard()
gtk_text_buffer_copy_clipboard()
gtk_text_buffer_cut_clipboard()

but they all require a GtkClipboard object as an argument.  After searching
through the API docs, I found out that I could get the default
clipboard as an object by passing GDK_NONE as the GdkAtom argument to
gtk_clipboard_get(), but I still keep getting these errors when the program
starts:

(application.exe:612): GLib-GObject-CRITICAL **: gtype.c:2254:
initialization asser
tion failed, use g_type_init() prior to this function

(application.exe:612): Gtk-CRITICAL **: gtk_clipboard_get_for_display:
assertion `G
DK_IS_DISPLAY (display)' failed

and these ones whenever I use the cut, copy and paste functions:

(application.exe:612): Gtk-CRITICAL **: gtk_clipboard_set_with_data:
assertion `cli
pboard != NULL' failed

(application.exe:612): Gtk-CRITICAL **: gtk_clipboard_request_contents:
assertion `
clipboard != NULL' failed

Is the gtk_clipboard_get() function not working properly?  Do these
clipboard functions just requrire an X server?  What's the deal?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

GtkTextTag usage

2005-12-16 Thread Nick Watts
I'm trying to implement syntax highlighting in my text widget.  Here is my
code:

static void create_tags(GtkTextBuffer *buffer)
   {
gtk_text_buffer_create_tag(buffer, doctype, background,
grey, editable, FALSE, NULL);
   }

static void text_changed(GtkTextBuffer *buffer, gpointer data)
   {
changed = 1;
GtkTextIter start;
GtkTextIter end;
gtk_text_buffer_get_iter_at_offset(buffer, start, 0);
gtk_text_buffer_get_iter_at_offset(buffer, end, -1);
gtk_text_buffer_remove_all_tags(buffer, start, end);
gtk_text_buffer_get_iter_at_line_offset(buffer, start, 0, 0);
gtk_text_buffer_get_iter_at_line_offset(buffer, end, 1, 0);
gtk_text_buffer_apply_tag_by_name(buffer, doctype, start,
end);
   }

The text_changed function is connected to the changed signal of the
buffer, and i can apply the tag fine, but when I start the application I get
this error:

(application.exe:2792): GtkWarning **: Unknown tag 'doctype'

It doesn't seem to have any affect so right now I'm just letting sleeping
dogs lie, but does anyone know what's wrong?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

activeX embedding

2005-12-14 Thread Nick Watts
Does anyone know if it is possible to embed an activeX control in a GTK+
app?  In particular the mozilla control or if I get desperate enough the IE
one?  For win32 so gtkmozembed is out although I'll probably use that when I
port to linux.

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

g_date_set_time error on folder selection

2005-10-16 Thread Nick Watts
On Windows XP. I've got a GtkFileChooser widget set up with the
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER action. Whenever I go to the My
Pictures directory with the file chooser widget, I get a whole bunch of
identical errors that all say:

Glib-CRITICAL **: g_date_set_time: assertion 'ptm != NULL' failed

Why does this happen for certain directories? Is there a way to fix it? I
think it may be the same error that is causing Inkscape to crash when I try
to look at the My Pictures folder as well.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


UI manager problem, more concise

2005-09-07 Thread Nick Watts
Umm, lets see. I have a whole bunch of UImanager code, but none of it causes 
an error until I get to this:

if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, error))
{
g_message (building menus failed: %s, error-message);
g_error_free (error);
}

The weird thing is that although I get a bunch of Gtk-CRITICAL errors in the 
program, the GError error is not set and the message is not 
displayed. Is there any problem with using the uimanager functions inside 
the main() or gtk_main() functions of your program?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Image display without window

2005-09-06 Thread Nick Watts
I've seen applications (eg. mozilla and blender) display an image at startup 
without any (visible) container such as a window or dialog.

I would like to add this touch of class to my app, anyone know the easiest 
way? I tried just adding a GtkImage to a GtkWindow, removing window 
decorations with gtk_window_set_decorated() and setting the container border 
width to 0, but there is still a grey border.

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


UIManager errors

2005-09-06 Thread Nick Watts
I'm trying to create a simple menu for my app with the new UIManager 
functions under GTK+ 2.6. I've copied most of my code for it from 
the the gtk-demo.exe app and I still can't get it to work. Compiles fine, 
but I get a long list of errors, all of which are like these (same error for 
similar code fragments):

Gtk-WARNING **: FileMenu: missing action
Gtk-CRITICAL **: gtk_container_foreach: assertion 
'GTK_IS_CONTAINER(container)' failed
Gtk-CRITICAL **: gtk_menu_shell_insert: assertion 
'GTK_IS_MENU_SHELL(menu_shell)' failed
Gtk-CRITICAL **: find_menu_position: assertion 
'GTK_IS_MENU_SHELL(menushell)' failed
Glib-GObject-WARNING **: invalid (NULL) pointer instance
Glib-GObject-CRITICAL **: g_signal_connect_data: assertion 
'G_TYPE_CHECK_INSTANCE(instance)' failed

I've been over the example and the API docs and I can't work out why this is 
happening. My code is below. If anyone can help I'd be very appreciative.

-Nick
**
static GtkActionEntry entries[] = {
{ Filemenu, NULL, _File },
{ Editmenu, NULL, _Edit },
{ Helpmenu, NULL, _Help },
{ New, GTK_STOCK_NEW, _New, controln, Create New File, 
G_CALLBACK(function_pendingm) },
{ Open, GTK_STOCK_OPEN, _Open, controlo, Open File, 
G_CALLBACK(function_pendingm) },
{ Save, GTK_STOCK_SAVE, _Save, controls, Save File, 
G_CALLBACK(function_pendingm) },
{ SaveAs, GTK_STOCK_SAVE, Save As, NULL, Save a Copy, 
G_CALLBACK(function_pendingm) },
{ Quit, GTK_STOCK_QUIT, _Quit, controlq, Quit ClearSky, 
G_CALLBACK(function_pendingm) },
{ Cut, GTK_STOCK_CUT, Cut, controlx, Cut Text, 
G_CALLBACK(function_pendingm) },
{ Copy, GTK_STOCK_COPY, Copy, controlc, Copy Text, 
G_CALLBACK(function_pendingm) },
{ Paste, GTK_STOCK_PASTE, Paste, controlv, Paste Text, 
G_CALLBACK(function_pendingm) },
{ SelectAll, NULL, Select _All, controla, Select All Text, 
G_CALLBACK(function_pendingm) },
{ Find, GTK_STOCK_FIND_AND_REPLACE, _Find and Replace, controlf, 
Find and Replace Text, G_CALLBACK(function_pendingm) },
{ Preferences, GTK_STOCK_PREFERENCES, Preferences, NULL, Set Viewing 
Preferences, G_CALLBACK(function_pendingm) },
{ HelpContents, GTK_STOCK_HELP, _Help Contents, controlh, View Help 
File Contents, G_CALLBACK(function_pendingm) },
{ About, GTK_STOCK_ABOUT, _About, controla, About ClearSky, 
G_CALLBACK(function_pendingm) }
};

static guint n_entries = G_N_ELEMENTS (entries);

static const gchar *ui_info = 
ui
 menubar name='MenuBar'
 menu action='FileMenu'
 menuitem action='New'/
 menuitem action='Open'/
 menuitem action='Save'/
 menuitem action='SaveAs'/
 separator/
 menuitem action='Quit'/
 /menu
 menu action='EditMenu'
 menuitem action='Cut'/
 menuitem action='Copy'/
 menuitem action='Paste'/
 menuitem action='SelectAll'/
 menuitem action='Find'/
 separator/
 menuitem action='Preferences'/
 /menu
 menu action='HelpMenu'
 menuitem action='HelpContents'/
 separator/
 menuitem action='About'/
 /menu
 /menubar
/ui;

GtkUIManager *ui;
GtkActionGroup *actions;
GError *error = NULL;

actions = gtk_action_group_new (Actions);
gtk_action_group_add_actions (actions, entries, n_entries, NULL);
ui = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (ui, actions, 0);
gtk_window_add_accel_group (GTK_WINDOW (window), 
gtk_ui_manager_get_accel_group (ui));

if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, error))
{
g_message (building menus failed: %s, error-message);
g_error_free (error);
}

gtk_box_pack_start (GTK_BOX(mainbox), gtk_ui_manager_get_widget(ui, 
/MenuBar), FALSE, FALSE, 0);
**
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Removing themes under win32

2005-09-05 Thread Nick Watts
I have installed the Wimp theme for GTK on windows and well... I hate it. 
GIMP now crashes when I create a new image!!!

How do I properly remove it and go back to the regular GTK+ look and feel?

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


Gdk Pixbuf file saving

2005-08-30 Thread Nick Watts
I am trying to create a simple photo resizing app and I can't get the 
gdk_pixbuf_save() function to work.
I have gdk_pixbuf_scale_simple() working so I evidently have the gdk

Here is my code:

==
static void save_image()
{
GdkPixbuf *savepixbuf;
savepixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
GError *error;
gdk_pixbuf_save(savepixbuf, filename, jpeg, error, quality, 100, 
NULL);
}

GtkWidget *img;
img = gtk_image_new_from_file(somephoto.jpg);
==

Compiles fine but upon attempting to save the file the GError returns thus:

message: \x08\x7f\xfc
code: 6770465
domain: G_FILE_ERROR

I can't figure out what's causing the error, if it's my code or if it is 
something OS related (using win32 and GTK+ 2.6).

Any help much appreciated,
-Nick
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GdkColor to Hexadecimal conversion

2005-08-17 Thread Nick Watts
Easiest way to convert a GdkColor to its hexadecimal equivalent?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Easiest way to get browser functionality embedded on win32?

2005-08-14 Thread Nick Watts
I'm writing my first mildly useful GTK+ app so still learning and I'd like 
to 
embed a web browser in it. I don't need to handle any input or output except 
getting 
it to load a HTML/Javascript file and render it properly.

What's the easiest way to do this in GTK+ for win32? Currently I'm looking 
at 
'porting' GtkMozEmbed as described at 
http://www.niccolai.ws/read_blob.php?news_id=18
to use in my app, but if there's an easier way (eg. a way to embed an active 
X control in a 
GTK+ app) I'd really like to hear it.

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