The time now is Thu 23 May 2013, 08:29
All times are UTC - 4 |
|
Page 6 of 12 [176 Posts] |
Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 Next |
| Author |
Message |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Wed 07 Mar 2012, 16:52 Post subject:
|
|
I'm anxious to see your notebook code.
This afternoon I took another tactic. I looked pretty hard at the 0.7. x series code and from the very first 0.7.4 it has really big changes all the way through, while 0.59.8 still looks much the same as 0.58.11. So, I started over with fresh 0.59.8 sources and did as I had with 0.58.1. I simply changed the configure.in and src/Makefile.am so that it would configure for gtk1. Then, I started running 'make 2> errors.txt' and looked at the result. For each error I found the spot in the sources and put 'ifdef USE_GTK' around the non-working lines. After about a half hour I had the thing compiling and linking -with nearly nothing working of course. Then, I cross-referenced with the last code from 0.58.10c and started pasting in your working code for the '#else'. In some places you seem to have replaced the original gtk2 with an equivalent which would work for either gtk1 or gtk2 -which is porbably a good thing in the long run. However, for now I have left the original gtk version and added the '#else' for your working gtk1/dual code. I also added in the pixmaps.h and misc.c which now holds the pixbuf-scaling routines. After just a little while I had the thing compiling and able to run the most basic widgets like the buttons, pixmaps, etc. I think there is still more to be done in some of the other files, but it will have to wait till tomorrow. I've left the original stuff in place with hardly any formatting changes (just a few of the same ones you had changed).
I think that it may be helpful to get this working and then aim for the 0.7.x series from this starting point. The changes in 0.7.x are, from the first, too many and complex for my abilities. You might find it easy enough to simply jump to 0.7.20 and dig in as you did before. Or it might be easier to start from this new base and work up through the original changes.
If you do start from 0.59.8, I'd recommend that you go through each official patch one-by-one and incorporate all the upstream changes, plus any minor details to make gtk1 work there as well. Hold off on adding extra features and even fixes for potential problems you see, until you get to the last version you want to target. Then, go through the whole code, make the formatting changes you want as a single patch/release without any real code changes *at all* -just formatting, whitespace, etc, whatever bother you. Then, go through again and start adding the fixes that see are useful, and then, finally, add in any extra features you have dreamed up along the way.
You don't need to make a new release for *every* one of the official versions which you have upgraded to -but I would, if I were you. Keep your versions limited to a manageable size, keep them easy to get an overview of and you won't be sorry. Usually when I do something like this, I create intermediate patches for each feature or fix which I implement. The patches may be useful to you later when you work on something else. Having each one contain just one 'bite', but a complete 'bite' of code which does just one thing, makes this lots easier.
We'll see how I do on the rest of 0.59.8 tomorrow. If it seems to be mostly working, we can easily switch to working there. If you have a chance to post or PM me your notebook code, I'll look at putting it into the base I am currently on -at the moment it is disabled, as are any other widgets which don't have corresponding gtk1 code.
|
|
Back to top
|
|
 |
goingnuts
Joined: 07 Dec 2008 Posts: 626
|
Posted: Fri 09 Mar 2012, 11:52 Post subject:
|
|
I am touching the 0.7.20... Following amigos advices above to leave the original code intact if possible. On top of that I would like to make a more general approach to back porting. So to avoid some of the "#ifdef USE_GTK2 stuff" and rewriting for (almost) simple syntax differences between gtk1&2 I have been experimenting with redefining gtk2 stuff that gtk1 does not understand. Made a new code and a new header file, compat.c and compat.h. compat.h is included in gtkdialog.h (just add #include "compat.h" to gtkdialog.h).
Content in compat.h is like this:
| Code: | #ifndef USE_GTK2
#define G_OBJECT GTK_OBJECT
#define GCallback GtkSignalFunc
#define g_signal_connect gtk_signal_connect
#define G_CALLBACK GTK_SIGNAL_FUNC
#endif
|
Now every code-snip of gtk2 like | Code: | g_signal_connect(G_OBJECT(widget), "button-press-event",
(GCallback) (on_any_widget_button_pressed),
(gpointer) Attr); |
is recognized by gtk1 and we avoid code like:
| Code: | #ifdef USE_GTK2
g_signal_connect(G_OBJECT(widget), "button-press-event",
(GCallback) (on_any_widget_button_pressed),
(gpointer) Attr);
#else
gtk_signal_connect(GTK_OBJECT(widget), "button-press-event",
GTK_SIGNAL_FUNC (on_any_widget_button_pressed),
(gpointer) Attr);
#endif
|
Same should be doable for functions - just put the bulk of the new functions in compat.c
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Fri 09 Mar 2012, 23:50 Post subject:
|
|
aren't macros great!
I was doing about the same thing with sdialog, but got sidetracked so its not very useful as is, but may save you time looking it up...
some(/most?) of them may actually need to be functions (if one function maps to several like gdk_atom_*) or at least have the function parameters defined in the macro (where number/position of args changes)
| Code: | /*
This data was gleaned from
http://developer.gnome.org/gtk/2.24/api-index-deprecated.html
http://developer.gnome.org/gtk/2.24/gtk-changes-2-0.html
http://developer.gnome.org/gtk/2.24/api-index-2-2.html and 2-4...2-24
and google search for gtkcompat.h turned up several hits
*/
#ifndef USE_GTK2
//this is just a bunch of stubs, using it will likely fry your box :P
#define G_PARAM_READABLE GTK_ARG_READABLE
#define G_PARAM_WRITABLE GTK_ARG_WRITABLE
#define G_PARAM_CONSTRUCT GTK_ARG_CONSTRUCT
#define G_PARAM_CONSTRUCT_ONLY GTK_ARG_CONSTRUCT_ONLY
#define g_signal_connect gtk_signal_connect
#define G_CALLBACK GTK_SIGNAL_FUNC
#define g_signal_emit_by_name gtk_signal_emit_by_name
#define gtk_adjustment_get_value(adj) adj->value
#define gtk_binding_entry_remove gtk_binding_entry_clear
#define gtk_binding_entry_add gtk_binding_entry_clear
#define g_type_check_instance_cast gtk_type_check_object_cast
#define g_type_check_class_cast gtk_type_check_class_cast
#define g_type_children gtk_type_children_types
#define g_enum_register_static gtk_type_register_enum
#define g_flags_register_static gtk_type_register_flags
#define g_type_parent gtk_type_parent_class
#define g_type_class_peek_parent gtk_type_parent_class
#define g_type_class_ref gtk_type_class
#define g_type_class_unref gtk_type_class
#define g_type_class_peek gtk_type_class
#define gtk_window_list_toplevels gtk_container_get_toplevels
#define GPatternSpec GtkPatternSpec
#define G_TYPE_FUNDAMENTAL GTK_FUNDAMENTAL_TYPE
#define G_TYPE_DERIVE_ID GTK_TYPE_MAKE
#define G_TYPE_BRANCH_SEQNO GTK_TYPE_SEQNO
#define GTK_<OBJECT>_GET_CLASS(object) object->klass //todo
#define GTK_CLASS_TYPE (class) object->type
#define gdk_drawable_get_size gdk_window_get_size
#define gdk_window_get_window_type gdk_window_get_type
#define gdk_drawable_get_colormap gdk_window_get_colormap
#define gdk_drawable_set_colormap gdk_window_set_colormap
#define gdk_drawable_get_visual gdk_window_get_visual
#define gdk_gc_unref gdk_gc_destroy
#define gdk_drawable_unref gdk_window_unref
#define gdk_image_unref gdk_image_destroy
#define gdk_cursor_unref gdk_cursor_destroy
#define gdk_draw_pixmap(drawable,gc,source_drawable,source_x,source_y,x,y,width,height) \
gdk_window_copy_area(drawable,gc,x,y,source_drawable,source_x,source_y,width,height)
#define gdk_rgb_get_colormap gdk_rgb_get_cmap
#define gtk_toolbar_new() gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL , GTK_TOOLBAR_BOTH )
#define gtk_widget_child_focus gtk_container_focus
#define set_child_property set_child_arg
#define get_child_property get_child_arg
#define gtk_container_class_install_child_property gtk_container_add_child_arg_type
#define gtk_container_class_list_child_properties gtk_container_query_child_args
#define gtk_container_child_set_property gtk_container_child_setv
#define gtk_container_child_get_property gtk_container_child_getv
#define gtk_container_add_with_properties gtk_container_add_with_args
#define gtk_container_add gtk_container_addv
#define gtk_container_child_set_property gtk_container_addv
#define gdk_drawable_get_image gdk_image_get
#define gtk_widget_set_size_request gtk_widget_set_usize
#define gtk_image_new_from_image gtk_image_new
#define MULTIPLE GTK_SELECTION_EXTENDED
#define gdk_x11_get_default_screen gdk_screen
#define gdk_x11_get_default_root_xwindow gdk_root_window
#define gdk_get_default_root_window gdk_root_parent
#define gdk_get_display gdk_display_name
void gdk_atom_intern (s, bool) {
//switch (s[3]) case D,T,P ????
//"WM_DELETE_WINDOW" gdk_wm_delete_window();
//"WM_TAKE_FOCUS" gdk_wm_take_focus()
//"WM_PROTOCOLS" gdk_wm_protocols()
}
#endif //USE_GTK2 |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
goingnuts
Joined: 07 Dec 2008 Posts: 626
|
Posted: Sat 10 Mar 2012, 05:19 Post subject:
|
|
technosaurus: Yes they are - and thanks for the list!
Now most of the pieces are in place - amigos 0.59 takes unmodified syntax (that is gtkdialog2 in puppy-world) and runs most of the widgets!
(@amigo: I revised it and have send the source).
The 0.7.20 compiles and takes original syntax as well (that is gtkdialog3 in puppy-world) although the widgets are hardly working and somewhat unstable...
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Sun 11 Mar 2012, 05:15 Post subject:
|
|
Sorry guys, I've been out of the loop since Thursday -having some blood-pressure problems. I owe you both a PM.
Technosaurus, that compat-header is a great idea and a great compendium of differences between gtk1/gtk2. Could we add some psuedo-stock-icon support got gtk1 in there?
About the syntax -is it just the '--program ???' vs. '--program=???' (MAIN_DIALOG as default) or are there other differences? Could a snippet be written which would accept either syntax?
|
|
Back to top
|
|
 |
goingnuts
Joined: 07 Dec 2008 Posts: 626
|
Posted: Sun 11 Mar 2012, 06:49 Post subject:
|
|
I have almost finalized a wrapper for the gtk2 syntax:
gtk_image_new_from_stock
which will support the script syntax:
<input file stock="gtk-zoom-out"></input>
and
<input file icon="about_kde"></input>
so at least the image files are recognized and used if found.
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Sun 11 Mar 2012, 09:25 Post subject:
|
|
Super! I've got your 0.59.8b running here. notebook widget seems to be fine.
I see you've even got some text functions in your wrapper -very nice!
|
|
Back to top
|
|
 |
goingnuts
Joined: 07 Dec 2008 Posts: 626
|
Posted: Sun 11 Mar 2012, 15:25 Post subject:
|
|
The wrapper for
gtk_image_new_from_file and gtk_image_new_from_stock
works now - and gives the gtk1 version support for stock and icon syntax.
Some of the examples wont run as we have disabled the chooser, gvim and tree. Thought that we should fix the code so the scripts run...
If the fileselect widget could be embedded it might replace chooser. I have to get a gvim to see if it is actually working already...and for the tree -
First try below:
| Description |
|
| Filesize |
11.49 KB |
| Viewed |
407 Time(s) |

|
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Sun 11 Mar 2012, 15:45 Post subject:
|
|
"disabled the chooser, gvim and tree" still enabled in the parser, so you only need to remove the ifdefs in the variuos spots in automaton.c
Yes, a fileselector could be used as the chooser -it is implemented but as an action so it's in action.c. I think the right form for the chooser would be to use gtk_fileselection_hide_fileops instead of gtk_fileselection_new
Nice about the tree -I figured you were gonna get there. Looking forward to a tarball soon so I can update stuff there. BTW, I had left out a couple of extra block of code where you added some actions to some widget -a quick comparison with your original sources will show them, or I'll look back and find them if you don't. Looking really great, man!
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Sun 11 Mar 2012, 15:59 Post subject:
|
|
looks nice!
you know ... putting some of these nuance macros (the general gtk1-gtk2 ones) into a single header file "gtk2compat.h" could be portable to other apps as well and significantly reduce the porting time for mainstream apps (not to mention making it easier to add to individual files within the project, just by adding a single #include) I'd be interested to take a look at this whenever you push another tarball.
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
goingnuts
Joined: 07 Dec 2008 Posts: 626
|
Posted: Mon 12 Mar 2012, 14:47 Post subject:
|
|
I might have given the impression that the tree is running - its not. Above image is a hard coded tree...but the structure should be there. I think it is even more complex than the tree in 0.59.8 which seems to be more or less like a table...no sub levels as far as I can see - EDIT: wrong - there are sublevels.
I will try to pipe tree-requests to the table widget - script syntax seems to be equal. EDIT: Did not work.
I think I might have found a good gtk1 replacement for the chooser in amigos repo: mytreefilesel. Image of it running below EDIT:Removed image. It will add to the size but should be possible to embed it. And it looks good!
EDIT: mytreefilesel is also a topwidget (as the fileselect widget) so wont easily embed in the main window (its a pop up/dialog...). Found a way to embed fileselect widget and the method should work for myfileselect as well. Still having problems with the signal connections though..but below the present parts of the gtk1 chooser wrapper:
| Code: | {
Widget=gtk_hbox_new(FALSE, 5);
GtkWidget* filesel = gtk_file_selection_new ("File selection");
gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(filesel));
gtk_object_destroy(GTK_FILE_SELECTION(filesel)->ok_button);
gtk_object_destroy(GTK_FILE_SELECTION(filesel)->cancel_button);
GtkWidget* file_main_vbox = GTK_FILE_SELECTION(filesel)->main_vbox;
gtk_widget_ref( file_main_vbox );
gtk_container_remove( GTK_CONTAINER(filesel), file_main_vbox);
gtk_box_pack_start(GTK_BOX(Widget), file_main_vbox, TRUE, TRUE, 0);
gtk_widget_unref( file_main_vbox );
gtk_widget_show( file_main_vbox );
}
push_widget(Widget, Widget_Type);
|
Image of the example chooser_test running with the embedded fileselect below.
Also attached the present source - still some fine tuning of the gtk1 needed - the label and images on buttons need careful alignment/padding to look good. Also the content in compat.c could be tighter and cleaner but thats for another day. It builds both in gtk1&2 but some warnings introduced...
| Description |
chooser_test running showing embedded fileselect |
| Filesize |
18.2 KB |
| Viewed |
371 Time(s) |

|
| Description |
|

Download |
| Filename |
gtkdialog1-0.59.8.snap20120312.tar.gz |
| Filesize |
416.13 KB |
| Downloaded |
94 Time(s) |
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Tue 13 Mar 2012, 02:43 Post subject:
|
|
I was just hacking around on mytreefilesel yesterday in fact, to clean up the interface abit. Thta comes from the sources of gtk-extra -I split it out long ago. Yes, it is lovely compared to anything else out there -it would be so nice to get this hacked into gtk itself as the file selector. It also gives some ideas on how to give rox a tree-view -as an option.
Note that, internally, mytreefilesel uses a ctree instead of a regular tree.
|
|
Back to top
|
|
 |
goingnuts
Joined: 07 Dec 2008 Posts: 626
|
Posted: Wed 14 Mar 2012, 15:35 Post subject:
|
|
Ok - I am stuck. Have spend a lot of time trying to modify the gtk1 fileselect popup-dialog to be more like the gtk2-chooser. The problem is how to get the path of the selected file. I have the code to get the filename but cant figure how to pull the path. Cant set up the right gtk_signal_connect it seems. The path is present in the pulldown_hbox and in the selection label, both are updated when directory are changed...
A have attached a simple example script which demonstrate the reparent process of the fileselect-popup to a main-widget and the callback that gets the filename (run it from console to view filename selected).
Any help would be appreciated. Basically 0.59.8 chooser only do the following as far as I can see:
GTK_FILE_CHOOSER_ACTION_OPEN
Indicates open mode. The file chooser will only let the user pick an existing file.
So its just a file chooser - but embedded in the main gtkdialog window - and not a pop-up dialog.
 |
| Description |
|

Download |
| Filename |
embedded_gtk1_fileselect.tar.gz |
| Filesize |
4.2 KB |
| Downloaded |
86 Time(s) |
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Wed 14 Mar 2012, 17:42 Post subject:
|
|
This link led me to dir_list
http://www.gtk.org/tutorial1.2/gtk_tut-9.html#ss9.14
found an example (gimp_path_editor_get_path) here:
http://www.rpi.edu/dept/acm/packages/gimp/gimp-1.2.3/libgimp/gimppatheditor.c
but maybe this is better as it does the base_dir
http://fossies.org/linux/misc/gcombust-0.1.55.tar.gz:a/gcombust-0.1.55/src/modify_file_set.c
| Quote: | gtk_file_selection_set_filename(GTK_FILE_SELECTION(sel), "");
dir_base = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sel)); |
gtk-server had better explanations for gtk1 than gtk's site
http://www.gtk-server.org/gtk1/gtk/gtkfileselection.html
I haven't played with Clists, but you may need to check first if it exists and then GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER or GTK_FILE_CHOOSER_ACTION_SAVE (this will let you pick an existing or create one ... is that the easy way?)
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
goingnuts
Joined: 07 Dec 2008 Posts: 626
|
Posted: Thu 15 Mar 2012, 02:00 Post subject:
|
|
technosaurus: Thanks! Your links brought me further - what a great place this is! I will post the working inline/embedded fileselect-example later today (will try to do some modifications of the widgets places first).
It now gives the full path + filename when the "selection_entry" change.
Update: Attached source for the skeleton code for the fileselect gtk1 widget that might be the chooser wrapper.
| Description |
|

Download |
| Filename |
gtk1_fileselect_inline.tar.gz |
| Filesize |
10.82 KB |
| Downloaded |
84 Time(s) |
| Description |
|
| Filesize |
10.13 KB |
| Viewed |
289 Time(s) |

|
|
|
Back to top
|
|
 |
|
|
Page 6 of 12 [176 Posts] |
Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 Next |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|