Re: ComboBox
gtk+2 itself is old, and if there is no other reason, you should (since you are new) use gtk+3. The documentation is at https://developer.gnome.org/gtk3/3.8/ On Thu, 2013-06-27 at 14:46 +0100, Rui Pedro Caldeira wrote: Hello guys, I'm new to GTK+ and I've run into a problem when creating a ComboBox. I'm using GTK+ 2.24.18 and following the tutorial from this page: https://developer.gnome.org/gtk-tutorial/2.24/x1063.html But when I try to compile the code, it seems that none of the functions I call exists in the gtk.h file Output: xxx.c: In function ‘XXX’: xxx.c:63:2: warning: implicit declaration of function ‘gtk_combo_new’ [-Wimplicit-function-declaration] xxx.c:63:8: warning: assignment makes pointer from integer without a cast [enabled by default] xxx.c:65:2: warning: implicit declaration of function ‘GTK_COMBO’ [-Wimplicit-function-declaration] xxx.c:65:101: error: invalid type argument of ‘-’ (have ‘int’) xxx.c:111:3: warning: statement with no effect [-Wunused-value] xxx.c:116:3: warning: format not a string literal and no format arguments [-Wformat-security] xxx.c:123:2: warning: implicit declaration of function ‘gtk_combo_set_popdown_strings’ [-Wimplicit-function-declaration] xxx.c:127:2: warning: implicit declaration of function ‘gtk_combo_set_use_arrows’ [-Wimplicit-function-declaration] xxx.c:54:6: warning: unused variable ‘status’ [-Wunused-variable] If you could help me I would be thankful Best regards, Rui ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: ComboBox
On Thu, 2013-06-27 at 16:42 +0002, Bernhard Schuster wrote: gtk-2.24 is still current in CentOS/RedHat Enterprise/Scientific Linux This List is probably long, I can add at least one more..SLED. thats what I meant (including others) as if there is no other reason :-) and static linking might be not allowed due to license restrictions. On Thu, Jun 27, 2013 at 6:09 PM, Rudra Banerjee rudra.baner...@aol.co.uk wrote: gtk+2 itself is old, and if there is no other reason, you should (since you are new) use gtk+3. The documentation is at https://developer.gnome.org/gtk3/3.8/ On Thu, 2013-06-27 at 14:46 +0100, Rui Pedro Caldeira wrote: Hello guys, I'm new to GTK+ and I've run into a problem when creating a ComboBox. I'm using GTK+ 2.24.18 and following the tutorial from this page: https://developer.gnome.org/gtk-tutorial/2.24/x1063.html But when I try to compile the code, it seems that none of the functions I call exists in the gtk.h file Output: xxx.c: In function ‘XXX’: xxx.c:63:2: warning: implicit declaration of function ‘gtk_combo_new’ [-Wimplicit-function-declaration] xxx.c:63:8: warning: assignment makes pointer from integer without a cast [enabled by default] xxx.c:65:2: warning: implicit declaration of function ‘GTK_COMBO’ [-Wimplicit-function-declaration] xxx.c:65:101: error: invalid type argument of ‘-’ (have ‘int’) xxx.c:111:3: warning: statement with no effect [-Wunused-value] xxx.c:116:3: warning: format not a string literal and no format arguments [-Wformat-security] xxx.c:123:2: warning: implicit declaration of function ‘gtk_combo_set_popdown_strings’ [-Wimplicit-function-declaration] xxx.c:127:2: warning: implicit declaration of function ‘gtk_combo_set_use_arrows’ [-Wimplicit-function-declaration] xxx.c:54:6: warning: unused variable ‘status’ [-Wunused-variable] If you could help me I would be thankful Best regards, Rui ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
help with about and help in gtk-app
Dear friends, I am writing a code with gtk+3. I am facing problems with linking the icons and help files with the code. #include config.h #include stdio.h #include stdlib.h #include glib/gi18n.h #include gdk-pixbuf/gdk-pixbuf.h #include gtk/gtk.h #include string.h GtkWidget *window; void help_about (GtkMenuItem *helpabout, GtkWidget *window) { const gchar *authors[] = { RudraB mai...@example.com, NULL }; const gchar *copyright = Copyright \xc2\xa9 2012-2013 Rudra Banerjee; const gchar *comments = _(Manage and Create BibTeX File); gchar *hstr=g_strdup_printf(%s/mkbib.svg, PIXMAP); g_print(%s,hstr); g_return_if_fail (GTK_IS_WIDGET (window)); gtk_show_about_dialog (GTK_IS_WINDOW (window) ? GTK_WINDOW (window) : NULL, name, _(mkbib), version, VERSION, copyright, copyright, comments, comments, authors, authors, logo-icon-name,hstr, license-type, GTK_LICENSE_GPL_3_0, screen, gtk_widget_get_screen (window), NULL); } void help_content(GtkWidget *widget, gpointer data) { gchar *uri, *str; GError *Err=NULL; uri=g_strdup(help:mkbib); gtk_show_uri(NULL, uri, gtk_get_current_event_time(), Err); g_free(uri); if (Err) { caution(File does not exist); } } I also have the pixbuff defined in the main.c as GdkPixbuf *create_pixbuf(const gchar * iconname) { GdkPixbuf *pixbuf; GError *error = NULL; pixbuf = gdk_pixbuf_new_from_file(iconname, error); if (!pixbuf) { fprintf(stderr, %s\n, error-message); g_error_free(error); } return pixbuf; } int main(int argc, char *argv[]) { gchar *sicon=g_strdup_printf(%s/icon.svg,PIXMAP); gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf(sicon)); g_free(sicon); } The problem is: 1) while the icon is shown in the topbar, as any gnome3 application, in About window, the icon is missing. but the pathe shown by g_print(%s,hstr); does exist. 2) the help files, in help/C/*.page is there, but Help-Help(i.e. F1) shows Quote: The URI ‘help:mkbib/index’ does not point to a valid page. . What I am missing? Kindly help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: help with about and help in gtk-app
I have solved the second problem (yelp only searches /usr/*, not $HOME). Any help on the first problem please? On Mon, 2013-06-10 at 16:53 +0100, Rudra Banerjee wrote: Dear friends, I am writing a code with gtk+3. I am facing problems with linking the icons and help files with the code. #include config.h #include stdio.h #include stdlib.h #include glib/gi18n.h #include gdk-pixbuf/gdk-pixbuf.h #include gtk/gtk.h #include string.h GtkWidget *window; void help_about (GtkMenuItem *helpabout, GtkWidget *window) { const gchar *authors[] = { RudraB mai...@example.com, NULL }; const gchar *copyright = Copyright \xc2\xa9 2012-2013 Rudra Banerjee; const gchar *comments = _(Manage and Create BibTeX File); gchar *hstr=g_strdup_printf(%s/mkbib.svg, PIXMAP); g_print(%s,hstr); g_return_if_fail (GTK_IS_WIDGET (window)); gtk_show_about_dialog (GTK_IS_WINDOW (window) ? GTK_WINDOW (window) : NULL, name, _(mkbib), version, VERSION, copyright, copyright, comments, comments, authors, authors, logo-icon-name,hstr, license-type, GTK_LICENSE_GPL_3_0, screen, gtk_widget_get_screen (window), NULL); } void help_content(GtkWidget *widget, gpointer data) { gchar *uri, *str; GError *Err=NULL; uri=g_strdup(help:mkbib); gtk_show_uri(NULL, uri, gtk_get_current_event_time(), Err); g_free(uri); if (Err) { caution(File does not exist); } } I also have the pixbuff defined in the main.c as GdkPixbuf *create_pixbuf(const gchar * iconname) { GdkPixbuf *pixbuf; GError *error = NULL; pixbuf = gdk_pixbuf_new_from_file(iconname, error); if (!pixbuf) { fprintf(stderr, %s\n, error-message); g_error_free(error); } return pixbuf; } int main(int argc, char *argv[]) { gchar *sicon=g_strdup_printf(%s/icon.svg,PIXMAP); gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf(sicon)); g_free(sicon); } The problem is: 1) while the icon is shown in the topbar, as any gnome3 application, in About window, the icon is missing. but the pathe shown by g_print(%s,hstr); does exist. 2) the help files, in help/C/*.page is there, but Help-Help(i.e. F1) shows Quote: The URI ‘help:mkbib/index’ does not point to a valid page. . What I am missing? Kindly help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
invalid utf-8 string pango warning
Hello gurus, I am a novice(both in C and in gtk+), but managed to create a parser that will create a tree from the parser. The problem is, in the minimal example posted in fpaste, if the line 264-266 is uncommented, i.e. I parse the same file twice, I get Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text() This reading the same file twice matches the exact behavior when I open and parse the file using filename=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); g_file_set_contents(filename, buffer, -1, Err); The code, sample example and makefile is at: http://paste.fedoraproject.org/13915/04195136/ http://paste.fedoraproject.org/13917/04584136/ http://paste.fedoraproject.org/13918/13693046/ Any help on where I am going wrong will be appreciated. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
better practice for work with saved buffer
hello friends, I am working on a gtk_list_store, that will save the rows to a file (set_contents(file, buffer)) After saving the datas to a file, without exiting, I will like to edit the file (as buffer) again. For that I have 2 option in my knowledge: 1) save the data, g_free(buffer), list_store_clear, reload the saved file 2) save the buffer to the file, but continue working with that without g_free(buffer) both seems to work, but which is the better practice? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
process flex+bison output in gtk hash table and list store
bibtex file is: @Book{a1, Title=ASR, Publisher=oxf, author = a {\m}ook, Rudra Banerjee, Year=2010, Address=UK, Edition=1, } @Booklet{ab19, Author=Rudra Banerjee and A. Mookerjee, Title=Fe{\Ni}Mo, Editor=sm1, Title=sm2, Publisher=sm3, Volume=sm4, Number=sm5, Pages=sm6, Month=sm8, Note=sm9, Key=sm10, Year=1980, Address=osm1, Edition=osm2, } I will be grateful if someone shows me some way to populate the hashtable correctly. Please help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
parsing bibtex using gscanner
Dear Friends, I am trying to parse a bibtex file using gscanner. The problem is that, due to many formats accepted by bibtex, it seems bit hard to parse it. What I mean is as long as the bibtex is of the form key=some value, then g_scanner_get_next_token can get the string. But it fails if it is in the format key={value}. I am attaching my code. Some help (outside using btparse/ bison )is needed. guint parse_entry (GScanner *scanner, GHashTable *table) { int tokount; /* Entry starts with @ */ g_scanner_get_next_token (scanner); if (scanner-token != '@') return G_TOKEN_ERROR; /* Now get identifier */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; g_hash_table_insert (table, g_strdup (type), g_strdup (scanner-value.v_identifier)); /* Brace */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_LEFT_CURLY){ return G_TOKEN_ERROR;} else tokount += tokount; /* ID */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; g_hash_table_insert (table, g_strdup (id), g_strdup (scanner-value.v_identifier)); while (TRUE) { char *key, *val; g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_COMMA) return G_TOKEN_ERROR; g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; key = g_strdup (scanner-value.v_identifier); /*g_scanner_peek_next_token (scanner); if (scanner-token == G_TOKEN_LEFT_CURLY) tokount += tokount;*/ g_scanner_get_next_token (scanner); if (scanner-token != '=') { g_free (key); return G_TOKEN_ERROR; } g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_STRING) { g_free (key); return G_TOKEN_ERROR; } val = g_strdup (scanner-value.v_string); g_hash_table_insert(table, key, val); g_scanner_peek_next_token (scanner); if (scanner-next_token == G_TOKEN_RIGHT_CURLY) break; } g_scanner_get_next_token (scanner); return G_TOKEN_NONE; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: parsing bibtex using gscanner
Below is a minimal example. One can check the problem with key={some value} by changing, say, author = \Chowdhury, D.\,\n to author = {Chowdhury, D.},\n This can be compiled as gcc -Wall `pkg-config --cflags --libs gtk+-3.0` glex.c /*glex.c*/ #include glib.h #include string.h /* Test data */ static const gchar *ttest = @phdthesis{chow1983thesis,\n author = \Chowdhury, D.\,\n institution = \Department of Physics, IIT, Kanpur\,\n location = \Kanpur\,\n publisher = \Department of Physics, IIT, Kanpur\,\n school = \Department of Physics, IIT, Kanpur\,\n title = \{The Spin Glass Transition}\,\n year = \1983\\n }; static void output_entry (GHashTable *table) { GHashTableIter iter; char *key, *val; g_print (Citation entry:\n); g_hash_table_iter_init (iter, table); while (g_hash_table_iter_next (iter, (void **)key, (void **)val)) g_print ( %16s: %s\n, key, val); g_print (\n); } static guint parse_entry (GScanner *scanner, GHashTable *table) { /* Entry starts with @ */ g_scanner_get_next_token (scanner); if (scanner-token != '@') return G_TOKEN_ERROR; /* Now get identifier */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; g_hash_table_insert (table, g_strdup (type), g_strdup (scanner-value.v_identifier)); /* Brace */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_LEFT_CURLY) return G_TOKEN_ERROR; /* ID */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; g_hash_table_insert (table, g_strdup (id), g_strdup (scanner-value.v_identifier)); while (TRUE) { char *key, *val; g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_COMMA) return G_TOKEN_ERROR; g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; key = g_strdup (scanner-value.v_identifier); g_scanner_get_next_token (scanner); if (scanner-token != '=') { g_free (key); return G_TOKEN_ERROR; } g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_STRING) { g_free (key); return G_TOKEN_ERROR; } val = g_strdup (scanner-value.v_string); g_hash_table_insert(table, key, val); g_scanner_peek_next_token (scanner); if (scanner-next_token == G_TOKEN_RIGHT_CURLY) break; } /* Eat last curly brace and return */ g_scanner_get_next_token (scanner); return G_TOKEN_NONE; } int main (intargc, char **argv) { GScanner *scanner; GHashTable *table; guint ret; scanner = g_scanner_new (NULL); g_scanner_input_text (scanner, ttest, strlen (ttest)); table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); do { g_hash_table_remove_all (table); ret = parse_entry (scanner, table); if (ret == G_TOKEN_ERROR) break; else output_entry (table); g_scanner_peek_next_token (scanner); } while (scanner-next_token != G_TOKEN_EOF scanner-next_token != G_TOKEN_ERROR); /* finsish parsing */ g_scanner_destroy (scanner); g_hash_table_destroy (table); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: parsing bibtex using gscanner
I forget the acknowledgment: http://www.gtkforums.com/viewtopic.php?f=3t=178159 On Mon, 2013-02-18 at 18:00 +, Rudra Banerjee wrote: Below is a minimal example. One can check the problem with key={some value} by changing, say, author = \Chowdhury, D.\,\n to author = {Chowdhury, D.},\n This can be compiled as gcc -Wall `pkg-config --cflags --libs gtk+-3.0` glex.c /*glex.c*/ #include glib.h #include string.h /* Test data */ static const gchar *ttest = @phdthesis{chow1983thesis,\n author = \Chowdhury, D.\,\n institution = \Department of Physics, IIT, Kanpur\,\n location = \Kanpur\,\n publisher = \Department of Physics, IIT, Kanpur\,\n school = \Department of Physics, IIT, Kanpur\,\n title = \{The Spin Glass Transition}\,\n year = \1983\\n }; static void output_entry (GHashTable *table) { GHashTableIter iter; char *key, *val; g_print (Citation entry:\n); g_hash_table_iter_init (iter, table); while (g_hash_table_iter_next (iter, (void **)key, (void **)val)) g_print ( %16s: %s\n, key, val); g_print (\n); } static guint parse_entry (GScanner *scanner, GHashTable *table) { /* Entry starts with @ */ g_scanner_get_next_token (scanner); if (scanner-token != '@') return G_TOKEN_ERROR; /* Now get identifier */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; g_hash_table_insert (table, g_strdup (type), g_strdup (scanner-value.v_identifier)); /* Brace */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_LEFT_CURLY) return G_TOKEN_ERROR; /* ID */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; g_hash_table_insert (table, g_strdup (id), g_strdup (scanner-value.v_identifier)); while (TRUE) { char *key, *val; g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_COMMA) return G_TOKEN_ERROR; g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_IDENTIFIER) return G_TOKEN_ERROR; key = g_strdup (scanner-value.v_identifier); g_scanner_get_next_token (scanner); if (scanner-token != '=') { g_free (key); return G_TOKEN_ERROR; } g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_STRING) { g_free (key); return G_TOKEN_ERROR; } val = g_strdup (scanner-value.v_string); g_hash_table_insert(table, key, val); g_scanner_peek_next_token (scanner); if (scanner-next_token == G_TOKEN_RIGHT_CURLY) break; } /* Eat last curly brace and return */ g_scanner_get_next_token (scanner); return G_TOKEN_NONE; } int main (intargc, char **argv) { GScanner *scanner; GHashTable *table; guint ret; scanner = g_scanner_new (NULL); g_scanner_input_text (scanner, ttest, strlen (ttest)); table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); do { g_hash_table_remove_all (table); ret = parse_entry (scanner, table); if (ret == G_TOKEN_ERROR) break; else output_entry (table); g_scanner_peek_next_token (scanner); } while (scanner-next_token != G_TOKEN_EOF scanner-next_token != G_TOKEN_ERROR); /* finsish parsing */ g_scanner_destroy (scanner); g_hash_table_destroy (table); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: parsing bibtex using gscanner
On Mon, 2013-02-18 at 19:02 +0100, David Nečas wrote: The best approach to parse a grammar is, you know, using a parser. So anything better then bison? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: parsing bibtex using gscanner
On Mon, 2013-02-18 at 19:02 +0100, David Nečas wrote: The best approach to parse a grammar is, you know, using a parser. So is there any better option then bison? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
use gchar as gtk_text_buffer: possible?
Can I have something like this? in main.h char* buffer; void in_program(){ gtk_text_buffer_set_modified (GTK_TEXT_BUFFER(buffer), TRUE); } I have defined buffer to have g_file_get_contents easily. So, any way to use gchar as gtk_text_buffer? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gscan text from textview and store it in treestore
Friends, I will be grateful if you kindly look at my post at http://stackoverflow.com/questions/14700104/gscan-text-from-textview-and-store-it-in-treestore I am not posting it here because, it contents moderate size of code which will be better seen as formatted. Thanks. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gtk-vim-syntax
Hi, I am using gtk-vim-syntax. As directed, I have copied it and :run glib.vim which highlights my glib commands. I tried to enable gtk3 as well by :run gtk3.vim but that is not highlighted. A screenshot to explain this is at http://imagebin.org/244914 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: is this correct way to open file in buffer?
Well, my final goal is to able to edit the file, but not save every time something has changed. So, in irc and other place, i was instructed to use get_contents method. Can you kindly clarify where I went wrong? On Wed, 2013-01-30 at 07:57 +0800, Gregory Hosler wrote: On 01/30/2013 07:39 AM, Rudra Banerjee wrote: Dear friends, I am trying hard to get rid of file reading and editing (as evident from my previous post) Here is a small code where I tried to open my file in a buffer and scan. Its small, 50 line code. I will be grateful if anybody kindly have a look and tell if this is really opening the file from buffer or still using the file. Please help. I am coming late into this thread, so please forgive the following question(s). I would like clarification opening the file from buffer or still using the file. In C, there is an api that allows us to open a file, and then associate a memory location with the file's contents. There after, any modification to the file, automatically shows in the buffer (i.e. no read() or re-read is required) and any modification to the file buffer will automatically show on disk (without the necessity of a write()). Is this what you are trying to do ? If yes, then the below will not accomplish this. The C api is to do a standard open(2) and then a mmap(2) to associate the file's buffer to a fixed memory location - I am happy to supply more details upon a confirmation. All the best, -Greg void open_file(GtkWidget *widget, gpointer data){ GScanner *scanner; GHashTable *table; char* fd; gsize length; GError* error=NULL; GtkWidget *dialog; //, *entry; GtkFileFilter *filter; dialog = gtk_file_chooser_dialog_new(Open File, NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, All files (*.*)); gtk_file_filter_add_pattern(filter, *); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, Bibtex file (*.bib)); gtk_file_filter_add_pattern(filter, *.bib); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); gtk_list_store_clear (store); g_file_get_contents(filename, fd, length , error); g_assert(!error); scanner = g_scanner_new (NULL); g_scanner_input_text (scanner, fd, CHAR_BUFF); table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); do { g_hash_table_remove_all (table); parse_entry (scanner, table); output_entry (table); g_scanner_peek_next_token (scanner); } while (scanner-next_token != G_TOKEN_EOF scanner-next_token != G_TOKEN_ERROR); /* finsish parsing */ g_scanner_destroy (scanner); g_hash_table_destroy (table); gtk_label_set_text(GTK_LABEL(flabel), filename); gtk_widget_destroy(dialog); } else gtk_widget_destroy(dialog); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
writing to a buffer: help
Dear friends, Please have a look at http://fpaste.org/gvF3/ So, I am writing those values to a string and then to a file(for now!) given that, Entries e are a structure, as, typedef struct { GtkWidget *combo, *entry1, *entryAuth, *entryEditor, *entryTitle, *entryPub, *entryVol, *entryIss, *entryPage, *entryMon, *entryNote, *entryKey, *entryYear, *entryAdd, *entryEdition, *entryJournal, *entrySeries, *entryBooktitle, *entryOrg, *entryChap, *entrySchool; } Entries; is there a better way of writing this; considering the fact that I have to check if any of the entry is NULL? My second question in this is that, I have created a buffer from a file in a different function as char* buffer; gsize length; GError* error=NULL; filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); g_file_get_contents(filename, buffer, length , error); I have not g_free-d it. Can I use the same buffer to if I want to append the buffer from update_file.c? Or should I g_free that buffer and reopen it? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: writing to a buffer: help
On Wed, 2013-01-30 at 16:32 +0100, Damien Caliste wrote: Is it clearer ? Much clearer! So, in a nutshell, as long as it is not free-ed, I can access it from any other function using char buffer and buffer, right? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: open an existing file in buffer and write on it
I tried a lot(trying to understand the huge GLib as suggested by Andrew), but most of the discussion here went way beyond my capability. So, lets try from fresh. My code for treeview and editing the treeview column (column Id #1). So, once the column is edited, its updated by the cell_edited. Now, I need to put this new_text in the file as well. The file that is read is a bibtex file (http://www.bibtex.org/Format/) GtkWidget *create_view_and_model(void) { GtkCellRenderer *cell; void cell_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, GtkTreeView *treeview); store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(tree), TRUE); /* #1: KEY COLUMN */ cell = gtk_cell_renderer_text_new (); g_object_set (cell, editable, TRUE, NULL); g_signal_connect (cell, edited,G_CALLBACK(cell_edited), tree); g_object_set_data (G_OBJECT (cell), column, GINT_TO_POINTER (COL_BIB_KEY)); GtkTreeViewColumn *col_key,*col_year,*col_type,*col_auth,*col_pub; col_key=gtk_tree_view_column_new_with_attributes ( Key, cell, text, COL_BIB_KEY, NULL); gtk_tree_view_column_set_sort_column_id( col_key, ID_KEY); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), col_key); gtk_tree_view_column_set_max_width (col_key,100); /* #2: TYPE COLUMN */ cell = gtk_cell_renderer_text_new (); col_type=gtk_tree_view_column_new_with_attributes ( Type, cell, text, COL_BIB_TYPE, NULL); gtk_tree_view_column_set_sort_column_id( col_type, ID_TYPE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), col_type); /* Three more such column of treeview */ return tree; } /* Apply the changed text to the cell if it is not an empty string. */ void cell_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, GtkTreeView *treeview) { guint column; GtkTreeIter iter; GtkTreeModel *model; gpointer columnptr = g_object_get_data(G_OBJECT(renderer), column); column = GPOINTER_TO_UINT(columnptr); if (g_ascii_strcasecmp (new_text, ) != 0) { model = gtk_tree_view_get_model (treeview); if (gtk_tree_model_get_iter_from_string (model, iter, path)) gtk_list_store_set (GTK_LIST_STORE (model), iter, column, new_text, -1); } } Kindly Help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
is this correct way to open file in buffer?
Dear friends, I am trying hard to get rid of file reading and editing (as evident from my previous post) Here is a small code where I tried to open my file in a buffer and scan. Its small, 50 line code. I will be grateful if anybody kindly have a look and tell if this is really opening the file from buffer or still using the file. Please help. void open_file(GtkWidget *widget, gpointer data){ GScanner *scanner; GHashTable *table; char* fd; gsize length; GError* error=NULL; GtkWidget *dialog; //, *entry; GtkFileFilter *filter; dialog = gtk_file_chooser_dialog_new(Open File, NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, All files (*.*)); gtk_file_filter_add_pattern(filter, *); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, Bibtex file (*.bib)); gtk_file_filter_add_pattern(filter, *.bib); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); gtk_list_store_clear (store); g_file_get_contents(filename, fd, length , error); g_assert(!error); scanner = g_scanner_new (NULL); g_scanner_input_text (scanner, fd, CHAR_BUFF); table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); do { g_hash_table_remove_all (table); parse_entry (scanner, table); output_entry (table); g_scanner_peek_next_token (scanner); } while (scanner-next_token != G_TOKEN_EOF scanner-next_token != G_TOKEN_ERROR); /* finsish parsing */ g_scanner_destroy (scanner); g_hash_table_destroy (table); gtk_label_set_text(GTK_LABEL(flabel), filename); gtk_widget_destroy(dialog); } else gtk_widget_destroy(dialog); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
change alternate treeview row color with css
I tried to change alternate row color of TreeView using css as: GtkCssProvider *provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, GtkTreeView {\n .row:nth-child(even): green;\n .row:nth-child(odd):red;\n }\n, -1, NULL); GdkDisplay *display = gdk_display_get_default (); GdkScreen *screen = gdk_display_get_default_screen (display); gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); This is giving runtime warning: (mkbib:6745): Gtk-WARNING **: Theme parsing error: data:2:1: Expected semicolon (mkbib:6745): Gtk-WARNING **: Theme parsing error: data:3:1: Expected semicolon Where I went wrong? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
open an existing file in buffer and write on it
Dear friends, as evident from my last few posts, I am struggling with opening a file as buffer and write to it (guess it has *nothing* to do with gtk, but C. Still I will be grateful if you people kindly help). So, first, how to open file in buffer? /* Files opened and edited directly*/ /* FILE *fop = fopen(filename, a ); if (!fop){ filename=Untitled.bib; fop= fopen(filename,a); } */ /*Trying to open file as buffer and edit that*/ FILE *fopf = fopen(filename, a ); if (!fopf){ filename=Untitled.bib; fopf= fopen(filename,a); } char fop[]=Hello World; int buf_size= strlen(fop)+1; fwrite(fop,buf_size,1,fopf); if(!fop){ printf(failed); } fclose(fopf); gtk_label_set_text(GTK_LABEL(flabel), filename); printf( fop, @%s{%s,\n, strcombo, strkey ); if( strlen(strAuth)!=0) printf( fop, \tAuthor=\%s\,\n, strAuth); if( strlen(strEditor)!=0) printf( fop, \tEditor=\%s\,\n, strEditor); if( strlen(strTitle)!=0) printf( fop, \tTitle=\%s\,\n, strTitle); // fclose(fop); The very first part of the code (commented) used to access the file directly, an approach that I was advised against. So I tried to open the file in buffer. But this implementation makes the program crash as soon as enter some value. Please help ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: open an existing file in buffer and write on it
ZZ, thanks for your comment! But is it so tough? database and all that? All I want to do is to have the ability of editing an existing file. Since directly editing the file is not recommended, this is the reason why I want to open it as buffer! On Fri, 2013-01-25 at 16:10 +0100, z...@excite.it wrote: On Friday 25 January 2013 14:57:23 Rudra Banerjee wrote: Dear friends, as evident from my last few posts, I am struggling with opening a file as buffer and write to it (guess it has *nothing* to do with gtk, but C. Still I will be grateful if you people kindly help). So, first, how to open file in buffer? /* Files opened and edited directly*/ /* FILE *fop = fopen(filename, a ); if (!fop){ filename=Untitled.bib; fop= fopen(filename,a); } */ /*Trying to open file as buffer and edit that*/ FILE *fopf = fopen(filename, a ); if (!fopf){ filename=Untitled.bib; fopf= fopen(filename,a); } You have to open, read (and then close) the file into a static or malloced buffer of sufficient size, then you can operate on the buffer. When your are done you write out the buffer to a newfile, delete the old and rename the new to old. char fop[]=Hello World; int buf_size= strlen(fop)+1; fwrite(fop,buf_size,1,fopf); if(!fop){ printf(failed); } fclose(fopf); gtk_label_set_text(GTK_LABEL(flabel), filename); printf( fop, @%s{%s,\n, strcombo, strkey ); if( strlen(strAuth)!=0) printf( fop, \tAuthor=\%s\,\n, strAuth); if( strlen(strEditor)!=0) printf( fop, \tEditor=\%s\,\n, strEditor); if( strlen(strTitle)!=0) printf( fop, \tTitle=\%s\,\n, strTitle); // fclose(fop); The very first part of the code (commented) used to access the file directly, an approach that I was advised against. So I tried to open the file in buffer. But this implementation makes the program crash as soon as enter some value. Please help PS.: at the first glance it seems to me you need a database backend like sqlite to save, store, change and retrieve your data. Ciao, ZZ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: open an existing file in buffer and write on it
Hi Damien, Thanks for your reply. What I have ended up with is something like: FILE *fopf = fopen(filename, a ); if (!fopf){ filename=Untitled.bib; fopf= fopen(filename,a); } char buffer[]=Hello World; int buf_size= strlen(buffer)+1; fwrite(buffer,buf_size,1,fopf); if(!buffer){ printf(failed); } // fclose(fopf); GString *fop=g_string_new(NULL); g_string_append_printf( fop,buffer); gtk_label_set_text(GTK_LABEL(flabel), filename); g_string_append_printf( fop, @%s{%s,\n, strcombo, strkey ); if( strlen(strAuth)!=0) g_string_append_printf( fop, \tAuthor=\%s\,\n, strAuth); if( strlen(strEditor)!=0) g_string_append_printf( fop, \tEditor=\%s\,\n, strEditor); if( strlen(strSchool)!=0) g_string_append_printf( fop, \tSchool=\%s\,\n, strSchool); g_string_append_printf( fop, }\n); // fclose(fop); g_file_set_contents(filename, fop, 1026, NULL); } But this writes the data in unformatted form. Can you kindly explain a bit more? On Fri, 2013-01-25 at 17:02 +0100, Damien Caliste wrote: Hello, Le 25/01/2013, Rudra Banerjee rudra.baner...@aol.co.uk a écrit : But is it so tough? database and all that? For managing several bibliography files, that should be better yes. All I want to do is to have the ability of editing an existing file. Since directly editing the file is not recommended, this is the reason why I want to open it as buffer! For just handling one file, that's not necessary of course. The idea when you want to change a file on disk is (not too big) : - generate a buffer of the full content of the file in memory, using GString for instance (http://developer.gnome.org/glib/unstable/glib-Strings.html) since they are automatically expending in size but can be used with equivalent printf() convenient functions ; - copy atomicaly the buffer in the file with g-file-set-contents() http://developer.gnome.org/glib/unstable/glib-File-Utilities.html#g-file-set-contents - delete the buffer. Damien. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
edit and use treeview cell
Friends, I am writing a gtk3(in C) code, that uses treeview. store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); cell = gtk_cell_renderer_text_new (); col_pub=gtk_tree_view_column_new_with_attributes ( Title, cell, text, COL_BIB_PUB, NULL); gtk_tree_view_column_set_sort_column_id( col_pub, ID_PUB); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), col_pub); The problem is I want each cell of the treeview to be editable, so I need something like: g_object_set(cell, editable, TRUE, NULL); but I have no idea of how to connect the edited flag to file/buffer. It will be very helpful if someone kindly show the way...a very short example may be. Please help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: edit and use treeview cell
On Thu, 2013-01-24 at 10:45 +0100, David Nečas wrote: Have you read the tutorial? http://scentric.net/tutorial/sec-editable-cells.html David, Thanks for your reply. Yes, I have read that tutorial. After reading that I have learned how to make the cell editable. But the problem still confuses me. And also, as I said, how to use this. That tut says I need a function cell_edited_callback to make the edit in file. But bit clueless about how to do that. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: edit and use treeview cell
Thanks ZZ, your code helped me making my code more general. Thanks a lot. Now I can edit the cells well. But my final goal is to write them in a file. I will check a bit and come back if I need further help. On Thu, 2013-01-24 at 15:18 +0100, z...@excite.it wrote: On Thursday 24 January 2013 11:02:37 Rudra Banerjee wrote: On Thu, 2013-01-24 at 10:45 +0100, David Nečas wrote: Have you read the tutorial? http://scentric.net/tutorial/sec-editable-cells.html David, Thanks for your reply. Yes, I have read that tutorial. After reading that I have learned how to make the cell editable. But the problem still confuses me. And also, as I said, how to use this. That tut says I need a function cell_edited_callback to make the edit in file. But bit clueless about how to do that. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list Hi, i used something like that in gtk2 and it used to work, hope it helps and is understandable as my code is sometimes a little bit convoluted as I'm self-taught, Ciao, ZZ static void list_edited(GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer user_data) { GtkTreeView *treeview = (GtkTreeView *)user_data; GtkTreeModel *model; GtkTreeIter iter; guint column; /* Column number is passed as renderer object data */ gpointer columnptr = g_object_get_data(G_OBJECT(cell), column); column = GPOINTER_TO_UINT(columnptr); /* Get the iterator */ model = gtk_tree_view_get_model(treeview); gtk_tree_model_get_iter_from_string(model, iter, path_string); /* Update the model */ gtk_list_store_set(GTK_LIST_STORE(model), iter, column, new_text, -1); } static void text_editing_started (GtkCellRenderer ATTRIBUTE_UNUSED *cell, GtkCellEditable *editable, const gchar *path, GCallback data) { debug_err_msg(%s: started, __FUNCTION__); if (GTK_IS_ENTRY (editable)) { GtkEntry *entry = GTK_ENTRY (editable); GCallback cb_func = data; g_signal_connect(GTK_OBJECT(entry), activate, (GCallback)cb_func, (char *)xstrdup(path)); } } GtkWidget *string_list_create(int num, GCallback func, int show_hide, int editable,...) { GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkListStore *store; GtkWidget *tree; GtkTreeSelection *selection; GType *types; va_list titles; int i; char *tmp; char *label; double align; types = (GType *) malloc((num + 1) * sizeof(GType)); for (i = 0; i num; i++) { types[i] = G_TYPE_STRING; } store = gtk_list_store_newv(num, types); xfree(types); tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); /* Setup the selection handler */ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); if (func) { g_signal_connect(selection, changed, G_CALLBACK(func), NULL); } /* The view now holds a reference. We can get rid of our own reference */ g_object_unref(G_OBJECT(store)); va_start(titles, editable); for (i = 0; i num; i++) { /* Create a cell renderer */ renderer = gtk_cell_renderer_text_new(); tmp = va_arg(titles, char *); align = va_arg(titles, double); if (editable == EDITABLE || (editable == CUSTOM va_arg(titles, int) == EDITABLE)) { g_object_set(renderer,editable, TRUE, NULL); g_object_set_data(G_OBJECT(renderer), column, GUINT_TO_POINTER(i)); g_signal_connect(GTK_OBJECT(renderer), edited, G_CALLBACK(list_edited), tree); if (editable == CUSTOM) { g_signal_connect(GTK_OBJECT(renderer), editing-started, G_CALLBACK(text_editing_started), (gpointer) va_arg(titles, void*)); } } if (!tmp || show_hide == HIDE ) tmp = ; if (g_utf8_validate(tmp, -1, NULL) != TRUE) { label = g_locale_to_utf8(tmp , -1, NULL, NULL, NULL); /* Create a column, associating the text attribute of the cell_renderer to the column of the model */ column = gtk_tree_view_column_new_with_attributes(label, renderer, text, i, NULL); xfree(label); } else { column = gtk_tree_view_column_new_with_attributes(tmp, renderer, text, i
change treeview's cell height
Dear friends, How can I change cell (and hence row) height of a given row? In my treeview, I have cells of fixed width, and I want texts longer than that should be wrapped with height increased. Any solution anyone? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: change treeview's cell height
Andrew, If I am not demanding to much, will you mind to have a look at the treeview defination that I posted? the problem is in treeview as written, store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(tree), TRUE); the rules_hint are not working, i.e. I am not getteing alternative color for each row. On Thu, 2013-01-24 at 23:47 +, Rudra Banerjee wrote: Thanks a lot! worked great! On Thu, 2013-01-24 at 15:42 -0800, Andrew Potter wrote: On Thu, Jan 24, 2013 at 3:33 PM, Rudra Banerjee rudra.baner...@aol.co.ukwrote: cell = gtk_cell_renderer_text_new (); col_auth=gtk_tree_view_column_new_with_attributes ( Author, cell, text, COL_BIB_NAME, NULL); gtk_tree_view_column_set_sort_column_id( col_auth, ID_NAME); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), col_auth); gtk_tree_view_column_set_max_width (col_auth,350); I googled the wrap_mode, but I haven't have any example. Please give me a short example(even one liner) try: g_object_set(G_OBJECT(cell), wrap-mode, PANGO_WRAP_WORD, wrap-width, 10, NULL); If the cell has more than 10 characters, it might wrap. Good luck! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: change treeview's cell height
Ok, no problem. Thanks for your time though. On Thu, 2013-01-24 at 16:21 -0800, Andrew Potter wrote: On Thu, Jan 24, 2013 at 4:00 PM, Rudra Banerjee rudra.baner...@aol.co.ukwrote: gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(tree), TRUE); the rules_hint are not working, i.e. I am not getteing alternative color for each row. I'm not an expert, but it probably means your default theme does not pay attention to that hint. This could be harder to diagnose since every Gtk3 release has had an evolved theme, and your distro may be changing it as well. What I would do is learn how to use the GtkCssProvider and make the rows the color you want. http://developer.gnome.org/gtk3/stable/GtkCssProvider.html Someone more knowledgeable than I might speak up though. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
css for button color
Dear friends, I have a periodic table application written in gtk2 (http://download.savannah.gnu.org/releases/ptbl/). I wrote it in gtk2 because gnome3.4 with default gtk+ theme Adwaita do not show colors of button for gtk3 app. Now, from gnome 3.6, this behavior is applied in gtk2 apps as well. I discussed this issue previously, with the suggestion that overriding theme is actually a bad idea, agreed. But for a app like periodic table, it is basic necessity. So, I, as suggested before, need to use css for the button colors. Can anybody kindly help me with creating css? Is gtkcssprovider usable in gtk2 as well? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
ghelp error
Dear friends, I know probably it has nothing to do with gtk, but I am trying to write the documentation of my gtk-related project. I am using the gnome-doc-utils method http://developer.gnome.org/gnome-doc-make/unstable/migrating.html.en My app-manual.xml in help/C/ is just a copy of what is given on the page, and so in the help/app-manual.omf.in My help/Makefile.am looks like: include $(top_srcdir)/gnome-doc-utils.make dist-hook: doc-dist-hook DOC_MODULE = app-manual DOC_ENTITIES = DOC_INCLUDES = DOC_FIGURES = images/app.png # figures/open_document.png DOC_LINGUAS = es sr en_GB DISTCLEANFILES = \ Makefile.in The problem is, yelp ghelp:app-manual says it does not point to a valid page. But if I manually do a yelp help/C/app-manual.xml its just working fine. Any idea? -- Rudra Banerjee A bus station is where a bus stops. A train station is where a train stops. On my desk I have a work station. Please, if possible, don't send me MS Word or PowerPoint attachments Why?See: http://www.gnu.org/philosophy/no-word-attachments.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
save as file submenu query
Dear friends, In my project, I have created a SAVE AS file submenu. I have two question: 1) This save as does not have any key board shortcut(Ctrl+S as standard) like open or new file submenu, which are also created in the same way, using accel group. Why this is so? 2) Though the file copying is working fine, I would love to receive some comment about if this is a dependable(in sense of failsafe and fast) process of copying file. The code is as follows: //In Main accel_group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); save = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE_AS, accel_group); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), save); g_signal_connect(G_OBJECT(save), activate, G_CALLBACK(rename_file), NULL); //the called function static void rename_file(GtkWidget *widget, gpointer data) { gchar *fname=NULL, *str; gchar *cts; GError *Err=NULL; GtkWidget *dialog; gsize length; dialog=gtk_file_chooser_dialog_new(Save File, GTK_WINDOW(window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { g_file_get_contents(filename, cts, length, Err); filename=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); g_file_set_contents(filename, cts, -1, Err); g_free(cts); if (Err) { caution(Failed to save in %s,filename); {g_free(str); g_error_free(Err);} } } gtk_widget_destroy(dialog); } Report this post ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
understanding GtkRGBA
Dear friends, though this might be Fedora(or gnome shell theme Adwaita) specific problem, I cannot get color from: GdkColor colorRed2 = {0x, 65535, 29555, 24158}; gtk_widget_modify_bg(button, GTK_STATE_NORMAL, colorRed2); So, I am trying to use: gtk_widget_override_background_color (Hbutton, GTK_STATE_NORMAL, GdkRGBA(0,0,0,1.)); ofcourse, this is not the way to use RGBA. What is the correct way of using it? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
link treeview with file
Dear friends, I have a query. As the treeview is loaded from a file, in my program, new entries can also be entered. It writes to the Treeview, as well as in a file using: strAuth = gtk_entry_get_text(GTK_ENTRY(e-entryAuth)); /*Entering the data in Treeview */ gtk_list_store_append(store, siter); gtk_list_store_set(store, siter, COL_BIB_KEY, strkey, COL_BIB_TYPE, strcombo, COL_BIB_NAME, strAuth, COL_BIB_YEAR, strYear, COL_BIB_PUB, strTitle, -1); /*Entering the data in file */ if( strlen(strEditor)!=0) g_fprintf( fop, \tEditor=\%s\,\n, strAuth); ...etc... Now, my question is, can this two entry be linked such that if I delete an entry from treeview, it will also delete the entry from file(fop). Report this post ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Sortable Treeview
Dear friends, I am trying to make a Treeview sortable. I have managed to get sortable by any one column, using GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store); Code: gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), ID_YEAR, GTK_SORT_ASCENDING); which will by default sort by year(or any ID_* that appear last), and treeview will get that view. What I am looking for, is make my header clickable to get the sorting, with initial view completely unsorted. I only managed to found this information: but I have no idea how. Can you kindly help a bit, typedef struct _Data { GtkWidget *window; GtkListStore *store; } Data; enum { C_TYPE = 0, C_NAME, C_YEAR, C_TITLE, NO_COLS }; enum { ID_TYPE = 0, ID_NAME, ID_YEAR, ID_TITLE }; static void create_gui (Data *data) { GtkWidget *vbox, *cbutton, *swindow, *tree; GtkCellRenderer *cell; data-window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (data-window), 400, 400); g_signal_connect (data-window, destroy, gtk_main_quit, NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); gtk_container_add (GTK_CONTAINER (data-window), vbox); cbutton = gtk_file_chooser_button_new (Load bib file, GTK_FILE_CHOOSER_ACTION_OPEN); g_signal_connect (cbutton, file-set, G_CALLBACK (cb_file_set), data); gtk_box_pack_start (GTK_BOX (vbox), cbutton, FALSE, FALSE, 0); swindow = gtk_scrolled_window_new (NULL, NULL); gtk_box_pack_start (GTK_BOX (vbox), swindow, TRUE, TRUE, 0); data-store = gtk_list_store_new (NO_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store); /* gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), ID_NAME, GTK_SORT_ASCENDING); */ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), ID_YEAR, GTK_SORT_ASCENDING); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (data-store)); gtk_container_add (GTK_CONTAINER (swindow), tree); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Type, cell, text, C_TYPE, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Name, cell, text, C_NAME, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Year, cell, text, C_YEAR, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Title, cell, text, C_TITLE, NULL); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree),TRUE); gtk_widget_show_all (vbox); } Report this post ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Sortable Treeview
Dear friends, I am trying to make a Treeview sortable. I have managed to get sortable by any one column, using GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store); Code: gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), ID_YEAR, GTK_SORT_ASCENDING); which will by default sort by year(or any ID_* that appear last), and treeview will get that view. What I am looking for, is make my header clickable to get the sorting, with initial view completely unsorted. I only managed to found this information: but I have no idea how. Can you kindly help a bit, typedef struct _Data { GtkWidget *window; GtkListStore *store; } Data; enum { C_TYPE = 0, C_NAME, C_YEAR, C_TITLE, NO_COLS }; enum { ID_TYPE = 0, ID_NAME, ID_YEAR, ID_TITLE }; static void create_gui (Data *data) { GtkWidget *vbox, *cbutton, *swindow, *tree; GtkCellRenderer *cell; data-window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (data-window), 400, 400); g_signal_connect (data-window, destroy, gtk_main_quit, NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); gtk_container_add (GTK_CONTAINER (data-window), vbox); cbutton = gtk_file_chooser_button_new (Load bib file, GTK_FILE_CHOOSER_ACTION_OPEN); g_signal_connect (cbutton, file-set, G_CALLBACK (cb_file_set), data); gtk_box_pack_start (GTK_BOX (vbox), cbutton, FALSE, FALSE, 0); swindow = gtk_scrolled_window_new (NULL, NULL); gtk_box_pack_start (GTK_BOX (vbox), swindow, TRUE, TRUE, 0); data-store = gtk_list_store_new (NO_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store); /* gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), ID_NAME, GTK_SORT_ASCENDING); */ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), ID_YEAR, GTK_SORT_ASCENDING); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (data-store)); gtk_container_add (GTK_CONTAINER (swindow), tree); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Type, cell, text, C_TYPE, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Name, cell, text, C_NAME, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Year, cell, text, C_YEAR, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1, Title, cell, text, C_TITLE, NULL); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree),TRUE); gtk_widget_show_all (vbox); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
improvements in gtktreeview
Dear friends, below I have copied the way I am creating a treeview. Maybe, you may find some part is not necessary, but still I put them to show you how I am doing the things. I need help in few things: 1) for my typical testing file, which has ~150 entry(to be parsed by parse.sh, create file fauth.dat and then read by fauth) It takes around 5 second! I am afraid what will happen for a bigger file. I tried to create a parser in C that will directly store the entries of fauth.dat in array, but failed(Any help in this will be hugely welcome). Is there anyway to sppedup the process ? 2) Entries in COL_BIB_NAME can be arbitraryly long(I have set up max length to 500). Problem is in my present settings, the full line is written in a single line. Can I set the width of each sell fixed? So, that when the entry is more then the width, they will break up in several line? In other word, currently, my cells have fixed hight, variable width. can I change it to variable hight, fixed width? 3) These two is my matter of concern. But being a novice, I am looking for any other advice as well. static GtkTreeModel * create_and_fill_model(void) { treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); return GTK_TREE_MODEL(treestore); } static GtkWidget * create_view_and_model(void) { GtkTreeViewColumn *col; GtkCellRenderer *renderer; GtkWidget *view; GtkTreeModel *model; view = gtk_tree_view_new(); /* --- Column #0 --- */ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, Type); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, text, COL_BIB_TYPE); /* --- Column #1 --- */ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, Name); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, text, COL_BIB_NAME); /* --- Column #2 --- */ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, Year); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, text, COL_BIB_YEAR); /*g_object_set(renderer, weight, PANGO_WEIGHT_BOLD, weight-set, TRUE, NULL); */ /* --- Column #3 --- */ col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, Journal); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, text, COL_BIB_PUB); /* connect a cell data function */ // gtk_tree_view_column_set_cell_data_func(col, renderer, age_cell_data_func, NULL, NULL); model = create_and_fill_model(); gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); g_object_unref(model); /* destroy model automatically with view */ gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_NONE); return view; } static void open_file(GtkWidget *widget, gpointer data) { GtkWidget *dialog; //, *entry; GtkFileFilter *filter; dialog = gtk_file_chooser_dialog_new(Open File, NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, All files (*.*)); gtk_file_filter_add_pattern(filter, *); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, Bibtex file (*.bib)); gtk_file_filter_add_pattern(filter, *.bib); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); char pcomm[1028]; sprintf(pcomm, bash parse.sh %s, filename); g_print(%s, pcomm); system((char *) pcomm); } int i=0;//,j=0,k=0; int num_line=0, ch; FILE *fauth, *fyear, *ftitle; FILE* tfauth=fopen(fauth.dat,r); do{ ch=fgetc(tfauth); if(ch == '\n') num_line++; }while (ch != EOF); /* if(ch != '\n' num_line != 0) num_line++;*/ fclose(tfauth); printf(%d\n,num_line); char
populate gtk tree view from outside
Dear friends, I have defined a treeview model as follows: enum { COL_FIRST_NAME = 0, COL_LAST_NAME, COL_YEAR_BORN, NUM_COLS } ; static GtkTreeModel * create_and_fill_model (void) { GtkTreeStore *treestore; GtkTreeItertoplevel, child; treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); int i; FILE *fauth; char alst[10][500], buffer[500]; fauth=fopen(fauth.dat,r); if(!fauth){ printf(fauth failed\n); } while(fgets(buffer,500,fauth)){ strcpy(alst[i],buffer); i++; } fclose(fauth); for (i = 0; i 10; i++){ gtk_tree_store_append(treestore, toplevel, NULL); gtk_tree_store_set(treestore, toplevel, COL_FIRST_NAME, alst[i], COL_LAST_NAME, Average, COL_YEAR_BORN, (guint) 1962, -1); } return GTK_TREE_MODEL(treestore); } static GtkWidget * create_view_and_model (void) { GtkTreeViewColumn *col; GtkCellRenderer *renderer; GtkWidget *view; GtkTreeModel*model; view = gtk_tree_view_new(); col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, First Name); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, text, COL_FIRST_NAME); gtk_tree_view_column_pack_start(col, renderer, TRUE); model = create_and_fill_model(); gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); g_object_unref(model); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_NONE); return view; } //For brevity, I have cut out the 2nd and 3rd column In a different function, I have strAuth = gtk_entry_get_text(GTK_ENTRY(e-entryAuth)); strEditor = gtk_entry_get_text(GTK_ENTRY(e-entryEditor)); Is it possible to add these strAuth, strEditor in those treeview's 1st and 2nd column? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: populate gtk tree view from outside
Oliver, Thanks a lot. Its working properly. Only change that I have made is using gtk_tree_store_append in place of gtk_tree_model_get_iter_first. Thanks a lot again. Regards, On Wed, 2012-09-12 at 21:31 +0200, Olivier Sessink wrote: On 09/12/2012 06:30 PM, Rudra Banerjee wrote: Oliver, Thanks for your reply. The problem basically is to pass on the function argument from one to other. you need to create a header file (main.h) that has the enum, and extern GtkListStore *treestore; in main.c define GtkListStore *treestore; somewhere in the top of fthe file, *not* inside a function. then include this both in main.c and in otherfile.c like #include main.h Olivier ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: glib array help
On Tue, 2012-09-11 at 12:16 +0700, Ardhan Madras wrote: As I already told you, this is a basic programming error but you event didn't notice it. So please find good C books and references out there and start learn how to write C program. Yes, I am also feeling that I need to learn C a fresh. My C knowledge is mostly based on web tutorials(like few tutorials given in tutorial section of gtkforum as well). Though I have a KR, I am ashemed to accept the fact that I have not managed to learn much from that. May I request you people to suggest me some good book that incorporates a lot of example? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
glib array help
Dear friends, I am trying to learn using glib array. From the gtk documentation, I managed to write this piece of code: #include stdio.h #include glib.h int main(int argc, char** argv) { int i; FILE *finp; char *alst[100]; GArray* a = g_array_new(FALSE, FALSE, sizeof(char*)); finp=fopen(fauth,r); for (i==0;i=100;i++){ fscanf(finp, %s, alst[i]); g_array_append_val(a, alst[i]); printf(%s, g_array_index(a, char*, i)); } printf(There are now %d items in the array\n, a-len); g_array_free(a, FALSE); return 0; } while compiling, its giving warning: $ gcc -Wall auc.c `pkg-config --cflags --libs gtk+-3.0` auc.c: In function ‘main’: auc.c:9:1: warning: statement with no effect [-Wunused-value] auc.c:10:9: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘char **’ [-Wformat] Can you kindly help me detecting the error? Typical file that I am using is: Taylor, DW, {\textbf{Banerjee, Rudra}} and Mookerjee, Abhijit and Sanyal, Biplab, {\textbf{R. Banerjee}} and Banerjee, M. and Majumdar, AK and Mookerjee, A. and Sanyal, B. and Hellsvik, J. and Eriksson, O. and Nigam, AK, {\textbf{Rudra Banerjee}} and Mookerjee, Abhijit, {\textbf{Rudra Banerjee}} and Mookerjee, Abhijit, Gyorffy, B. L. and Pindor, A. J. and Staunton, J. and Stocks, G. M. and Winter, H., Abdul-Razzaq, W. and Kouvel, JS, Aitken, RG and Cheung, TD and Kouvel, JS and Hurdequint, H., Alam, A. and Mookerjee, A., Alam, A. and Mookerjee, A., ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
parsing bibtex with GKeyFile parser
I am thinking of possibility of parsing a bibtex file with gkeyfile parser. bibtex has the structure like: @Book{a, Author=b and q and r, s , Editor=c, Title=d, } Any idea? or any other way to parse it within C(and gtk)? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gscanner example
I tried to rewrite the example given in the page http://www.fifi.org/doc/libgtk1.2-doc/faq-html/gtkfaq-8.html so that it can read from a file, but its not. The code that i tried is: #include glib.h /* some test text to be fed into the scanner */ /*static const gchar *test_text = ( ping = 5;\n / * slide in some \n * comments, just for the\n * fun of it \n * /\n zonk = 0.7;\n pong = -6; \n \n # the next value is a float\n # redefine ping\n ping = - 0.5;\n ); */ /* define enumeration values to be returned for specific symbols */ enum { SYMBOL_PING = G_TOKEN_LAST + 1, SYMBOL_PONG = G_TOKEN_LAST + 2, SYMBOL_ZONK = G_TOKEN_LAST + 3 }; /* symbol array */ static const struct { gchar *symbol_name; guint symbol_token; } symbols[] = { { Author, SYMBOL_PING, }, { Title, SYMBOL_PONG, }, { zonk, SYMBOL_ZONK, }, { NULL, 0, }, }, *symbol_p = symbols; static gfloat ping = 0; static gfloat pong = 0; static gfloat zonk = 0; static guint parse_symbol (GScanner *scanner) { guint symbol; gboolean negate = FALSE; /* expect a valid symbol */ g_scanner_get_next_token (scanner); symbol = scanner-token; if (symbol SYMBOL_PING || symbol SYMBOL_ZONK) return G_TOKEN_SYMBOL; /* expect '=' */ g_scanner_get_next_token (scanner); if (scanner-token != '=') return '='; /* feature optional '-' */ g_scanner_peek_next_token (scanner); if (scanner-next_token == '-') { g_scanner_get_next_token (scanner); negate = !negate; } /* expect a float (ints are converted to floats on the fly) */ g_scanner_get_next_token (scanner); if (scanner-token != G_TOKEN_FLOAT) return G_TOKEN_FLOAT; /* make sure the next token is a ';' */ if (g_scanner_peek_next_token (scanner) != ';') { /* not so, eat up the non-semicolon and error out */ g_scanner_get_next_token (scanner); return ';'; } /* assign value, eat the semicolon and exit successfully */ switch (symbol) { case SYMBOL_PING: ping = negate ? - scanner-value.v_float : scanner-value.v_float; break; case SYMBOL_PONG: pong = negate ? - scanner-value.v_float : scanner-value.v_float; break; case SYMBOL_ZONK: zonk = negate ? - scanner-value.v_float : scanner-value.v_float; break; } g_scanner_get_next_token (scanner); return G_TOKEN_NONE; } int main (int argc, char *argv[]) { GScanner *scanner; guint expected_token; scanner = g_scanner_new (NULL); /* adjust lexing behaviour to suit our needs */ /* convert non-floats (octal values, hex values...) to G_TOKEN_INT */ scanner-config-numbers_2_int = TRUE; /* convert G_TOKEN_INT to G_TOKEN_FLOAT */ scanner-config-int_2_float = TRUE; /* don't return G_TOKEN_SYMBOL, but the symbol's value */ scanner-config-symbol_2_token = TRUE; /* load symbols into the scanner */ while (symbol_p-symbol_name) { g_scanner_add_symbol (scanner, symbol_p-symbol_name, GINT_TO_POINTER (symbol_p-symbol_token)); symbol_p++; } gint file=1; file=g_open(trial.bib, r); /* feed in the text */ g_scanner_input_file (scanner, file); /* give the error handler an idea on how the input is named */ // scanner-input_name = test text; /* scanning loop, we parse the input until its end is reached, * the scanner encountered a lexing error, or our sub routine came * across invalid syntax */ do { expected_token = parse_symbol (scanner); g_scanner_peek_next_token (scanner); } while (expected_token == G_TOKEN_NONE scanner-next_token != G_TOKEN_EOF scanner-next_token != G_TOKEN_ERROR); /* give an error message upon syntax errors */ // if (expected_token != G_TOKEN_NONE) //g_scanner_unexp_token (scanner, expected_token, NULL, symbol, NULL, NULL, TRUE); /* finsish parsing */ g_scanner_destroy (scanner); /* print results */ g_print (ping: %s\n, ping); g_print (pong: %s\n, pong); g_print (zonk: %f\n, zonk); return 0; } what is error in it? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
path for icon
Dear friends, in my GTK(3) app, I am using icons as gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf(images/icon.svg)); or GtkWidget *ast4im = gtk_image_new_from_file (images/mkb3.png); The problem is, when I am running the app away from the source directory, those images are broken, obviously due to the fact that the path is missing. One solution is to put absolute path, but then the code will not be portable. Is there any better way of doing it? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
compile multiple source file
I have two file: #THE MAIN### #include gtk/gtk.h int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *button; gtk_init (argc, argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); button = gtk_button_new_with_label (Hello World); g_signal_connect (button, clicked, G_CALLBACK (hello), NULL); gtk_container_add (GTK_CONTAINER (window), button); gtk_widget_show (button); gtk_widget_show (window); gtk_main (); return 0; } #hello.c #include gtk/gtk.h static void hello( GtkWidget *widget, gpointer data ) { g_print (Hello World\n); } If they are in separate file, then, $ gcc `pkg-config --cflags --libs gtk+-3.0` hello.c main.c -c main.c: In function ‘main’: main.c:13:5: error: ‘hello’ undeclared (first use in this function) main.c:13:5: note: each undeclared identifier is reported only once for each function it appears in But obviously, putting both of them together in a single file works. How to compile while keeping them seperate ? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: compile multiple source file
Thanks Olivier and all, The static was the culprit. -- Rudra JRF; SNBNCBS http://www.bose.res.in/~rudra A bus station is where a bus stops. A train station is where a train stops. On my desk I have a work station. Please, if possible, don't send me MS Word or PowerPoint attachments Why?See: http://www.gnu.org/philosophy/no-word-attachments.html From: Olivier Sessink oliviersess...@gmail.com To: gtk-app-devel-list@gnome.org Sent: Friday, 31 August 2012 4:02 PM Subject: Re: compile multiple source file On 08/31/2012 04:48 PM, Rudra Banerjee wrote: If they are in separate file, then, $ gcc `pkg-config --cflags --libs gtk+-3.0` hello.c main.c -c main.c: In function ‘main’: main.c:13:5: error: ‘hello’ undeclared (first use in this function) main.c:13:5: note: each undeclared identifier is reported only once for each function it appears in But obviously, putting both of them together in a single file works. How to compile while keeping them seperate first remove the 'static' keyword before function hello(), static functions are only called from the file itself, they are not to be called from other files. now create a header file hello.h that contains: void hello( GtkWidget *widget, gpointer data ); and include that in main.c like #include hello.h now you can compile each .c file, and then link the resulting .o files to a binary. Olivier ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
button background color in gtk3
Friends, I am putting gtkbuttons inside a grid with modify_bg. I am getting an odd case that when the window is focused, all buttons are showing white, not what suggested by modify_bg. The same structure was working fine in gtk2 (while I was using table instead of grid). I am posting the complete minimal code(60 line only) for your reference. I have seen that the gtk_widget_modify_bg is deprecated in gtk 3 so I tried the suggested method with gtk_widget_override_background_color but there it seems that declaration of GdkColor colorRed2 = {0x, 65535, 29555, 24158} has changed to something like GdkRGBA. I tried to change to GdkRGBA colorRed = {1,0,0,1}; yeilding error: ‘const struct GdkRGBA *’ but argument is of type ‘GdkRGBA’ Please Help. here is the complete code: #include gtk/gtk.h int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *grid; GtkWidget *menubar; GtkWidget *filemenu; GtkWidget *quit; GtkAccelGroup *accel_group = NULL; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), Try Grid); gtk_container_set_border_width(GTK_CONTAINER(window), 05); grid = gtk_grid_new(); gtk_container_add(GTK_CONTAINER(window), grid); gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE); gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE); menubar = gtk_menu_bar_new(); filemenu = gtk_menu_new(); accel_group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); GtkWidget *file = gtk_menu_item_new_with_mnemonic(_File); quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel_group); gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file); g_signal_connect(G_OBJECT(quit), activate, G_CALLBACK(gtk_main_quit), NULL); gtk_grid_attach(GTK_GRID(grid), menubar, 0, 0, 2, 1); /* Color Scheme */ GdkColor colorRed2 = {0x, 65535, 29555, 24158}; GdkColor colorBlue = {0x, 3598, 57054, 61937}; GdkColor colorWht = {0x, 65535, 65535, 65535}; GtkWidget *Abutton = gtk_button_new_with_label(A); gtk_grid_attach(GTK_GRID(grid), Abutton, 0, 1, 1, 1); gtk_widget_modify_bg(Abutton, GTK_STATE_NORMAL, colorBlue); gtk_widget_modify_bg(Abutton, GTK_STATE_PRELIGHT, colorWht); /* Create second button */ GtkWidget *Bbutton = gtk_button_new_with_label(B); gtk_grid_attach(GTK_GRID(grid), Bbutton, 10, 1, 1, 1); gtk_widget_modify_bg(Bbutton, GTK_STATE_NORMAL, colorRed2); gtk_widget_modify_bg(Bbutton, GTK_STATE_PRELIGHT, colorWht); gtk_widget_show_all(window); gtk_main(); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: auto refresh file in textview
I will be really grateful if someone help me in the problem. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: auto refresh file in textview
I am sorry but I really don't know how to write on a buffer. I am writing on the file as: FILE *fop = fopen(filename, a ); g_fprintf( fop, @%s{%s,\n, strcombo, strkey ); g_fprintf( fop, \tAuthor=%s,\n, strAuth); etc. and the buffer is defined as static void read_view(char *inpfn) { char *buffer; stat(inpfn, filestat); textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); buffer = (char *) malloc(filestat.st_size * sizeof (char)); efile = fopen(inpfn, r); fread(buffer, filestat.st_size, 1, efile); gtk_text_buffer_set_text(textbuffer, buffer, filestat.st_size); free(buffer); } Can you please give me a hint how to write on a buffer? I am a novice, hope you will be kind. On Fri, 2012-08-24 at 13:33 +0100, jcup...@gmail.com wrote: Hi Rudra, On 23 August 2012 13:45, Rudra Banerjee bnrj.ru...@yahoo.com wrote: whenever I am writing, it is saved, but to see the change, I have to reopen the file(obviously). What do you need to know? Do you want your textview to update as the file changes? If your program is appending to the file as well as displaying in the textview, it would be much simpler just to append to the textview itself. John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: auto refresh file in textview
Please ignore the previous post. google is giving some hints. I will comeback if I failed. On Fri, 2012-08-24 at 14:41 +0100, Rudra Banerjee wrote: I am sorry but I really don't know how to write on a buffer. I am writing on the file as: FILE *fop = fopen(filename, a ); g_fprintf( fop, @%s{%s,\n, strcombo, strkey ); g_fprintf( fop, \tAuthor=%s,\n, strAuth); etc. and the buffer is defined as static void read_view(char *inpfn) { char *buffer; stat(inpfn, filestat); textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); buffer = (char *) malloc(filestat.st_size * sizeof (char)); efile = fopen(inpfn, r); fread(buffer, filestat.st_size, 1, efile); gtk_text_buffer_set_text(textbuffer, buffer, filestat.st_size); free(buffer); } Can you please give me a hint how to write on a buffer? I am a novice, hope you will be kind. On Fri, 2012-08-24 at 13:33 +0100, jcup...@gmail.com wrote: Hi Rudra, On 23 August 2012 13:45, Rudra Banerjee bnrj.ru...@yahoo.com wrote: whenever I am writing, it is saved, but to see the change, I have to reopen the file(obviously). What do you need to know? Do you want your textview to update as the file changes? If your program is appending to the file as well as displaying in the textview, it would be much simpler just to append to the textview itself. John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
auto refresh file in textview
Dear friends, I am openning an existing file in textview from command line as: textview = gtk_text_view_new(); gtk_container_add(GTK_CONTAINER(scrolledwindow), textview); textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); if (argc 1 argv[1] != NULL) { char *flnm = argv[1]; read_view(flnm); } where the read_view is defined as: static void read_view(char *inpfn) { char *buffer; stat(inpfn, filestat); textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); buffer = (char *) malloc(filestat.st_size * sizeof (char)); efile = fopen(inpfn, r); fread(buffer, filestat.st_size, 1, efile); gtk_text_buffer_set_text(textbuffer, buffer, filestat.st_size); free(buffer); } I am writing in the file that is opened as: FILE *fop = fopen(filename, a ); g_fprintf( fop, @%s{%s,\n, strcombo, strkey ); where the fileopen is difined globally. whenever I am writing, it is saved, but to see the change, I have to reopen the file(obviously). I checked a post in gtkforums but cant manage much (http://www.gtkforums.com/viewtopic.php?f=3t=11443) . I also tried the gtk manual on GFileMonitor and failed. May I request your time for kind help? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: write to a file using g_print
Thanks! Its working excellent. Now, I have another small problem. I have opened a file from the menubar filechooser dialog as: static void open_file(GtkWidget *widget, gpointer data) { GtkWidget *dialog;//, *entry; dialog = gtk_file_chooser_dialog_new(Open File, GTK_WINDOW(window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { char *filename; filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); read_view(filename); g_print(filename); } gtk_widget_destroy(dialog); } I would like to append this file from another function: static void activate_func(GtkWidget *widget, gpointer data) { /* OTHER STAFF */ FILE *fop = fopen(file.bib, a ); g_fprintf( fop, @%s{%s,\n, strcombo, strkey ); /*ETC*/ } instead of fopen(file.bib,a), I tried fopen(open_file( *widget, data,filename),a) and also adjusted the argument of open_file. but its not working. How I can transfer the filename from open_file to activate_func? On Wed, 2012-08-22 at 07:45 +0800, Ardhan Madras wrote: g_open() is wrapper to open() syscall, not the standard libc's fopen(). mkbib.c:114:15: warning: initialization makes pointer from integer without a cast [enabled by default] You got this because g_open() returning a int (file descriptor) not a FILE pointer. You must distinguish each I/O method that you are using and don't mess with it. You can't use a file descriptor to standard libc's I/O functions, use FILE pointer instead. #include glib.h #include glib/gstdio.h #include stdio.h FILE *fop = open(bib2.bib, w); /* you can call g_fprintf() or fprintf() */ see man 3 printf Is it possible to write to a file using g_print? g_print() already write to standard output FILE, but you can dup() standard output to another file. Regards. On Wed, Aug 22, 2012 at 6:42 AM, Rudra Banerjee bnrj.ru...@yahoo.com wrote: Is it possible to write to a file using g_print? I was trying something like: FILE *fop = g_open(bib2.bib,w); g_print (%s%s,strcombo,strkey, fop); but its not working. Even fprintf is giving warning and not writing. mkbib.c:114:15: warning: initialization makes pointer from integer without a cast [enabled by default] mkbib.c:115:3: warning: passing argument 1 of ‘fprintf’ from incompatible pointer type [enabled by default] Any solution? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
write to a file using g_print
Is it possible to write to a file using g_print? I was trying something like: FILE *fop = g_open(bib2.bib,w); g_print (%s%s,strcombo,strkey, fop); but its not working. Even fprintf is giving warning and not writing. mkbib.c:114:15: warning: initialization makes pointer from integer without a cast [enabled by default] mkbib.c:115:3: warning: passing argument 1 of ‘fprintf’ from incompatible pointer type [enabled by default] Any solution? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Open file from menu
Will anyone kindly show the way? -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Rudra Banerjee bnrj.ru...@yahoo.com wrote: Dear friends, I am trying to create a textview that will show the file opens. I have managed to make it read the commandline argument as: stat(argv[1], filestat); buffer = (char *) malloc(filestat.st_size * sizeof (char)); efile = fopen(argv[1], r); fread(buffer, filestat.st_size, 1, efile); gtk_text_buffer_set_text(textbuffer, buffer, filestat.st_size); free(buffer); But I am facing 2 problem(2nd problem is more important to solve). 1) putting the above block inside if (argv[1] != NULL) is giving a segmentation fault: [Thread debugging using libthread_db enabled] Using host libthread_db library /lib64/libthread_db.so.1. Program received signal SIGSEGV, Segmentation fault. 0x00364066c81e in fread () from /lib64/libc.so.6 and 2) How I can open the file using file menu, instead of commandline argument? I have defined the menu as follows: file = gtk_menu_item_new_with_mnemonic(_File); new = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, accel_group); open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, accel_group); sep = gtk_separator_menu_item_new(); quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel_group); gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), new); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), open); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), sep); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3); g_signal_connect(G_OBJECT(new), activate, G_CALLBACK(filenew_activated), (gpointer) window); g_signal_connect(G_OBJECT(open), activate, G_CALLBACK(fileopen_activated), (gpointer) window); g_signal_connect_swapped(G_OBJECT(window), destroy, G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(quit), activate, G_CALLBACK(gtk_main_quit), NULL); which is opening the file selector, but *NOT* writing it in the textview. I wish to open the file in textview and save it aswell after I edit that. If anyone kindly show the how-to, I can put problem (1) to solve later. Please help. _ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Open file from menu
Dear friends, I am trying to create a textview that will show the file opens. I have managed to make it read the commandline argument as: stat(argv[1], filestat); buffer = (char *) malloc(filestat.st_size * sizeof (char)); efile = fopen(argv[1], r); fread(buffer, filestat.st_size, 1, efile); gtk_text_buffer_set_text(textbuffer, buffer, filestat.st_size); free(buffer); But I am facing 2 problem(2nd problem is more important to solve). 1) putting the above block inside if (argv[1] != NULL) is giving a segmentation fault: [Thread debugging using libthread_db enabled] Using host libthread_db library /lib64/libthread_db.so.1. Program received signal SIGSEGV, Segmentation fault. 0x00364066c81e in fread () from /lib64/libc.so.6 and 2) How I can open the file using file menu, instead of commandline argument? I have defined the menu as follows: file = gtk_menu_item_new_with_mnemonic(_File); new = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, accel_group); open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, accel_group); sep = gtk_separator_menu_item_new(); quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel_group); gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), new); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), open); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), sep); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3); g_signal_connect(G_OBJECT(new), activate, G_CALLBACK(filenew_activated), (gpointer) window); g_signal_connect(G_OBJECT(open), activate, G_CALLBACK(fileopen_activated), (gpointer) window); g_signal_connect_swapped(G_OBJECT(window), destroy, G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(quit), activate, G_CALLBACK(gtk_main_quit), NULL); which is opening the file selector, but *NOT* writing it in the textview. I wish to open the file in textview and save it aswell after I edit that. If anyone kindly show the how-to, I can put problem (1) to solve later. Please help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: multiple GTKentry inside a GTKnotebook
Mariano, Thanks for your help. But this is not what I am looking for. What I want is I will choose the combobox entry and fill up the entry box data manually. Then if I click ok button, it will append an external file with those data. Please see the quoted reply I made in this thread to your previous reply. Hope, I have cleared my intention. By this code, what I want to achieve is that: After choosing book/loco/lardon etc as done by you, this will print the active_data in combobox and Entries in a file. So, if the combo entry is Book and entryAuth is MyAuthor entryEditor is MyEditor entryTitle is MyTitle and bibkey is Mybib then according to file selected(new/old) it will write there @book{MyBib Author=MyAuthor Title=MyTitle } ofcourse the formatting can be done later. My current problem in hand is to get those text like Book, MyAuthor, Mybib etc as a variable to use. I googled and found some example but not working. Last but not the least, thanks Mariano for exporting it to GTK3. its really looks nice. On Sun, 2012-06-24 at 01:15 -0300, Mariano Gaudix wrote: Rudra can see the example . I uploaded a new code .downloads in .. MEDIAFIRE .. http://www.mediafire.com/?4l8qo1wtk35dcqb Rudra , let me know if you will download , the example. 2012/6/24 Rudra Banerjee bnrj.ru...@yahoo.com Friends, Plz show me how to do that. On Mon, 2012-06-18 at 23:28 +0530, Rudra Banerjee wrote: Friends, pasted is a minimal layout of my trial to create a bibliography maker. The problem is, in Authors tab inside notebook, I want to edit 3 more entry, as Editor an example. But its taking only the first entry. Please show me where I am making the error. (NB. I am neither a C programmer nor GTK. I am creating this via reading various tutorials. So please don't get too irritated) #include gtk/gtk.h #include stdio.h #include string.h #include gdk/gdk.h GtkWidget *window; GtkWidget *vbox, *hbox, *combo; GtkWidget *entry1; GtkWidget *entryAuth; GtkWidget *entryEdit; GtkWidget *window; #include menubar.c int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *table; GtkWidget *frame; GtkWidget *notebook; GtkWidget *label; GtkWidget *checkbutton; int i; char bufferf[32]; char bufferl[32]; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), BibMk); gtk_container_set_border_width(GTK_CONTAINER(window), 20); g_signal_connect(window, delete-event, G_CALLBACK(gtk_main_quit), NULL); vbox = gtk_vbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), hbox); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new(Properties); combo = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Book); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Article); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); gtk_widget_show(combo); entry1 = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry1), bibKey); gtk_box_pack_start(GTK_BOX(hbox), entry1, TRUE, TRUE, 0); gtk_widget_show(entry1); /* * CREATE THE NOTEBOOK PAN */ table = gtk_table_new(3,6,FALSE); /* Create a new notebook, place the position of the tabs */ notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1); gtk_widget_show(notebook); /* * CREATE BASIC NOTEBOOK */ /* * Authors Tab */ frame = gtk_frame_new (Authors); gtk_container_set_border_width (GTK_CONTAINER (frame), 10); gtk_widget_set_usize (frame, 400, 175); entryAuth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryAuth), Author
Re: multiple GTKentry inside a GTKnotebook
Friends, Plz show me how to do that. On Mon, 2012-06-18 at 23:28 +0530, Rudra Banerjee wrote: Friends, pasted is a minimal layout of my trial to create a bibliography maker. The problem is, in Authors tab inside notebook, I want to edit 3 more entry, as Editor an example. But its taking only the first entry. Please show me where I am making the error. (NB. I am neither a C programmer nor GTK. I am creating this via reading various tutorials. So please don't get too irritated) #include gtk/gtk.h #include stdio.h #include string.h #include gdk/gdk.h GtkWidget *window; GtkWidget *vbox, *hbox, *combo; GtkWidget *entry1; GtkWidget *entryAuth; GtkWidget *entryEdit; GtkWidget *window; #include menubar.c int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *table; GtkWidget *frame; GtkWidget *notebook; GtkWidget *label; GtkWidget *checkbutton; int i; char bufferf[32]; char bufferl[32]; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), BibMk); gtk_container_set_border_width(GTK_CONTAINER(window), 20); g_signal_connect(window, delete-event, G_CALLBACK(gtk_main_quit), NULL); vbox = gtk_vbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), hbox); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new(Properties); combo = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Book); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Article); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); gtk_widget_show(combo); entry1 = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry1), bibKey); gtk_box_pack_start(GTK_BOX(hbox), entry1, TRUE, TRUE, 0); gtk_widget_show(entry1); /* * CREATE THE NOTEBOOK PAN */ table = gtk_table_new(3,6,FALSE); /* Create a new notebook, place the position of the tabs */ notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1); gtk_widget_show(notebook); /* * CREATE BASIC NOTEBOOK */ /* * Authors Tab */ frame = gtk_frame_new (Authors); gtk_container_set_border_width (GTK_CONTAINER (frame), 10); gtk_widget_set_usize (frame, 400, 175); entryAuth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryAuth), Author); gtk_container_add (GTK_CONTAINER (frame), entryAuth); gtk_widget_show (entryAuth); entryAuth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryEdit), Editor); gtk_container_add (GTK_CONTAINER (frame), entryEdit); gtk_widget_show (entryEdit); label = gtk_label_new (Authors/Title); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label); gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); gtk_widget_show(table); gtk_widget_show_all(window); gtk_main(); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: multiple GTKentry inside a GTKnotebook
By this code, what I want to achieve is that: After choosing book/loco/lardon etc as done by you, this will print the active_data in combobox and Entries in a file. So, if the combo entry is Book and entryAuth is MyAuthor entryEditor is MyEditor entryTitle is MyTitle and bibkey is Mybib then according to file selected(new/old) it will write there @book{MyBib Author=MyAuthor Title=MyTitle } ofcourse the formatting can be done later. My current problem in hand is to get those text like Book, MyAuthor, Mybib etc as a variable to use. I googled and found some example but not working. Last but not the least, thanks Mariano for exporting it to GTK3. its really looks nice. On Thu, 2012-06-21 at 11:03 -0300, Mariano Gaudix wrote: How is the program you want to do? Can you explain? 2012/6/21 Rudra Banerjee bnrj.ru...@yahoo.com Thanks, but its not solving the main problem. / 2012/6/20 Rudra Banerjee bnrj.ru...@yahoo.com Olivier, Thanks for your interest. Pasted just below is the complete code. What I want to do with that is, as a raw commented snip by line number 106-116 that according to my selection of Book/Article in combobox, some entry will be hidden. But, for that, I need to get the data from the combo box, which I have tried in line number 53-54. Please help. NB. Olivier, I got your reply in CC as well as a group post. So, I am replying you also(reply to all). Please don't get offended if it was not your intention. /***THE CODE/ #include gtk/gtk.h #include stdio.h #include string.h #include gdk/gdk.h GtkWidget *window; GtkWidget *vbox, *hbox, *combo; GtkWidget *vbox1, *hbox1, *combo1; GtkWidget *entry1; GtkWidget *entryAuth; GtkWidget *entryEditor; GtkWidget *entryTitle; GtkWidget *window; int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *table; GtkWidget *frame; GtkWidget *notebook; GtkWidget *label; GtkWidget *checkbutton; GtkWidget *widget; int i; char bufferf[32]; char bufferl[32]; //char bibtype; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), BibMk); gtk_container_set_border_width(GTK_CONTAINER(window), 20); g_signal_connect(window, delete-event, G_CALLBACK(gtk_main_quit), NULL); // gtk_window_set_default_size(GTK_WINDOW(window), 200, 150); vbox = gtk_vbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), hbox); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new(Properties); combo = gtk_combo_box_text_new(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Book); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Article); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); gtk_widget_show(combo); gchar *bibtype = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); printf(%s, gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo))); entry1 = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry1), bibKey); gtk_box_pack_start(GTK_BOX(hbox), entry1, TRUE, TRUE, 0); gtk_widget_show(entry1); /* * CREATE THE NOTEBOOK PAN */ table
Re: multiple GTKentry inside a GTKnotebook
Olivier, Thanks for your interest. Pasted just below is the complete code. What I want to do with that is, as a raw commented snip by line number 106-116 that according to my selection of Book/Article in combobox, some entry will be hidden. But, for that, I need to get the data from the combo box, which I have tried in line number 53-54. Please help. NB. Olivier, I got your reply in CC as well as a group post. So, I am replying you also(reply to all). Please don't get offended if it was not your intention. /***THE CODE/ #include gtk/gtk.h #include stdio.h #include string.h #include gdk/gdk.h GtkWidget *window; GtkWidget *vbox, *hbox, *combo; GtkWidget *vbox1, *hbox1, *combo1; GtkWidget *entry1; GtkWidget *entryAuth; GtkWidget *entryEditor; GtkWidget *entryTitle; GtkWidget *window; int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *table; GtkWidget *frame; GtkWidget *notebook; GtkWidget *label; GtkWidget *checkbutton; GtkWidget *widget; int i; char bufferf[32]; char bufferl[32]; //char bibtype; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), BibMk); gtk_container_set_border_width(GTK_CONTAINER(window), 20); g_signal_connect(window, delete-event, G_CALLBACK(gtk_main_quit), NULL); //gtk_window_set_default_size(GTK_WINDOW(window), 200, 150); vbox = gtk_vbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), hbox); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new(Properties); combo = gtk_combo_box_text_new(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Book); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Article); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); gtk_widget_show(combo); gchar *bibtype = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); printf(%s, gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo))); entry1 = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry1), bibKey); gtk_box_pack_start(GTK_BOX(hbox), entry1, TRUE, TRUE, 0); gtk_widget_show(entry1); /* * CREATE THE NOTEBOOK PAN */ table = gtk_table_new(3, 6, FALSE); /* Create a new notebook, place the position of the tabs */ notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0, 6, 0, 1); gtk_widget_show(notebook); /* * CREATE BASIC NOTEBOOK */ /* * Authors Tab */ frame = gtk_frame_new(Authors); gtk_widget_set_usize(frame, 400, 175); vbox1 = gtk_vbox_new(FALSE, 0); hbox1 = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox1); entryAuth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryAuth), Author); gtk_container_add (GTK_CONTAINER (vbox1), entryAuth); gtk_widget_show(entryAuth); entryEditor = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryEditor), Editor); gtk_container_add (GTK_CONTAINER (vbox1), entryEditor); gtk_widget_show(entryEditor); entryTitle = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryTitle), Title); gtk_container_add (GTK_CONTAINER (vbox1), entryTitle); gtk_widget_show(entryTitle); label = gtk_label_new(Authors/Title); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), frame, label); /*switch (bibtype) { case book: gtk_container_add(GTK_CONTAINER(vbox1), entryAuth); gtk_container_add(GTK_CONTAINER(vbox1), entryEditor); gtk_entry_set_text(GTK_ENTRY(entryTitle), Title); break; case article: gtk_container_add(GTK_CONTAINER(vbox1), entryAuth); gtk_entry_set_text(GTK_ENTRY(entryTitle), Title); } */ gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); gtk_widget_show(table); gtk_widget_show_all(window); gtk_main(); return 0; } /***CODE END**/ On Wed, 2012-06-20 at 13:20 +0200, Olivier Sessink wrote: can you post a larger bit of the code? it is difficult to see what's going on. b.t.w. gtk_combo_box_new_text() is deprecated, use gtk_combo_box_text_new() Olivier 2012/6/20 Rudra Banerjee bnrj.ru...@yahoo.com: Thanks for your reply jjacky. This is a mistake; but does not changeing the result. On Tue, 2012-06-19 at 22:13 +0200, jjacky wrote: On 06/19/12 21:43, Rudra Banerjee wrote: Yeti, Thanks for your help. That is working now. it should probably be GTK_COMBO_BOX(combo), not GTK_COMBO_BOX(widget) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk
Re: multiple GTKentry inside a GTKnotebook
Thanks, but its not solving the main problem. / 2012/6/20 Rudra Banerjee bnrj.ru...@yahoo.com Olivier, Thanks for your interest. Pasted just below is the complete code. What I want to do with that is, as a raw commented snip by line number 106-116 that according to my selection of Book/Article in combobox, some entry will be hidden. But, for that, I need to get the data from the combo box, which I have tried in line number 53-54. Please help. NB. Olivier, I got your reply in CC as well as a group post. So, I am replying you also(reply to all). Please don't get offended if it was not your intention. /***THE CODE/ #include gtk/gtk.h #include stdio.h #include string.h #include gdk/gdk.h GtkWidget *window; GtkWidget *vbox, *hbox, *combo; GtkWidget *vbox1, *hbox1, *combo1; GtkWidget *entry1; GtkWidget *entryAuth; GtkWidget *entryEditor; GtkWidget *entryTitle; GtkWidget *window; int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *table; GtkWidget *frame; GtkWidget *notebook; GtkWidget *label; GtkWidget *checkbutton; GtkWidget *widget; int i; char bufferf[32]; char bufferl[32]; //char bibtype; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), BibMk); gtk_container_set_border_width(GTK_CONTAINER(window), 20); g_signal_connect(window, delete-event, G_CALLBACK(gtk_main_quit), NULL); //gtk_window_set_default_size(GTK_WINDOW(window), 200, 150); vbox = gtk_vbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), hbox); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new(Properties); combo = gtk_combo_box_text_new(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Book); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Article); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); gtk_widget_show(combo); gchar *bibtype = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); printf(%s, gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo))); entry1 = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry1), bibKey); gtk_box_pack_start(GTK_BOX(hbox), entry1, TRUE, TRUE, 0); gtk_widget_show(entry1); /* * CREATE THE NOTEBOOK PAN */ table = gtk_table_new(3, 6, FALSE); /* Create a new notebook, place the position of the tabs */ notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0, 6, 0, 1); gtk_widget_show(notebook); /* * CREATE BASIC NOTEBOOK */ /* * Authors Tab */ frame = gtk_frame_new(Authors); gtk_widget_set_usize(frame, 400, 175); vbox1 = gtk_vbox_new(FALSE, 0); hbox1 = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox1); entryAuth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryAuth), Author); gtk_container_add (GTK_CONTAINER (vbox1), entryAuth); gtk_widget_show(entryAuth); entryEditor = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryEditor), Editor); gtk_container_add (GTK_CONTAINER (vbox1), entryEditor); gtk_widget_show(entryEditor); entryTitle = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryTitle), Title); gtk_container_add (GTK_CONTAINER (vbox1), entryTitle); gtk_widget_show(entryTitle); label = gtk_label_new(Authors/Title); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), frame, label); /*switch (bibtype
Re: multiple GTKentry inside a GTKnotebook
Yeti, Thanks for your help. That is working now. I have one more problem. I need to take the data from the combo box. So after the combo box, I added the line: gchar *bibtype = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget)); fprintf(stdout, %s, bibtype); So, that part looks like combo = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Book); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Article); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); gtk_widget_show(combo); gchar *bibtype = gtk_combo_box_get_active_text (GTK_COMBO_BOX(widget)); fprintf(stdout, %s, bibtype); which is giving error. I am trying hard via tutorials in web from yesterday. Please help. On Mon, 2012-06-18 at 20:35 +0200, David Nečas wrote: On Mon, Jun 18, 2012 at 11:28:48PM +0530, Rudra Banerjee wrote: pasted is a minimal layout of my trial to create a bibliography maker. The problem is, in Authors tab inside notebook, I want to edit 3 more entry, as Editor an example. But its taking only the first entry. Please show me where I am making the error. GtkFrame is a GtkBin which means it can contain a single widget. If you want more you need to use packing container (GtkTable, GtkVBox, GtkGrid, ...), put it to the frame and then pack widgets to this contaner. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: multiple GTKentry inside a GTKnotebook
Thanks for your reply jjacky. This is a mistake; but does not changeing the result. On Tue, 2012-06-19 at 22:13 +0200, jjacky wrote: On 06/19/12 21:43, Rudra Banerjee wrote: Yeti, Thanks for your help. That is working now. it should probably be GTK_COMBO_BOX(combo), not GTK_COMBO_BOX(widget) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
multiple GTKentry inside a GTKnotebook
Friends, pasted is a minimal layout of my trial to create a bibliography maker. The problem is, in Authors tab inside notebook, I want to edit 3 more entry, as Editor an example. But its taking only the first entry. Please show me where I am making the error. (NB. I am neither a C programmer nor GTK. I am creating this via reading various tutorials. So please don't get too irritated) #include gtk/gtk.h #include stdio.h #include string.h #include gdk/gdk.h GtkWidget *window; GtkWidget *vbox, *hbox, *combo; GtkWidget *entry1; GtkWidget *entryAuth; GtkWidget *entryEdit; GtkWidget *window; #include menubar.c int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *table; GtkWidget *frame; GtkWidget *notebook; GtkWidget *label; GtkWidget *checkbutton; int i; char bufferf[32]; char bufferl[32]; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), BibMk); gtk_container_set_border_width(GTK_CONTAINER(window), 20); g_signal_connect(window, delete-event, G_CALLBACK(gtk_main_quit), NULL); vbox = gtk_vbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), hbox); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); frame = gtk_frame_new(Properties); combo = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Book); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), Article); gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); gtk_widget_show(combo); entry1 = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry1), bibKey); gtk_box_pack_start(GTK_BOX(hbox), entry1, TRUE, TRUE, 0); gtk_widget_show(entry1); /* * CREATE THE NOTEBOOK PAN */ table = gtk_table_new(3,6,FALSE); /* Create a new notebook, place the position of the tabs */ notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1); gtk_widget_show(notebook); /* * CREATE BASIC NOTEBOOK */ /* * Authors Tab */ frame = gtk_frame_new (Authors); gtk_container_set_border_width (GTK_CONTAINER (frame), 10); gtk_widget_set_usize (frame, 400, 175); entryAuth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryAuth), Author); gtk_container_add (GTK_CONTAINER (frame), entryAuth); gtk_widget_show (entryAuth); entryAuth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entryEdit), Editor); gtk_container_add (GTK_CONTAINER (frame), entryEdit); gtk_widget_show (entryEdit); label = gtk_label_new (Authors/Title); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label); gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); gtk_widget_show(table); gtk_widget_show_all(window); gtk_main(); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Table not visible
Is it possible to show a minimal example(or a webpage with such tutorial?)? or atleast direct me where I need to make change? Rudra Banerjee JRF, SNBNCBS http://www.bose.res.in/~rudra প্রতিদিন সূর্য ওঠে তোমায় দেখবে বলে, ও আমার আগুন তুমি আবার ওঠো জ্বলে If possible, plz. don't send me MsWord/PowerPoint mails. Why? See http://www.gnu.org/philosophy/no-word-attachments.html On Tue, May 8, 2012 at 5:17 PM, Olivier Sessink oliviersess...@gmail.com wrote: On 05/09/2012 07:10 AM, Rudra Banerjee wrote: Dear friends, I am a newbie in GTK and also in C itself. I am trying to develop a table (thanks to awesome tutorials available). I am currently facing a problem. In the given code, its working fine. Posted is a minimal example I managed to generate. The problem is in line 88 and 89, either of table or menu is working. If I comment one line, other one is working. Where I went wrong? Please show. the window can only hold 1 widget. so add a vbox to the window, add the menubar to the vbox add the table also to the vbox Olivier ___ 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 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
xml parse
Friends, I have an xml file. I want to search its Author and Year from GTK entry. The xml file looks like this: xml records record database name=My Collection.enl path=My Collection.enlMy Collection.enl/database ref-type name=Journal Article0/ref-type contributors authors authorBanerjee, Mitali/author authorBanerjee, Rudra/author authorMajumdar, a.K./author authorMookerjee, Abhijit/author authorSanyal, Biplab/author authorNigam, a.K./author /authors /contributors titles title Magnetism in NiFeMo disordered alloys: Experiment and theory /title secondary-titlePhysica B: Condensed Matter/secondary-title /titles periodical full-titlePhysica B: Condensed Matter/full-title /periodical pages4287-4293/pages volume405/volume issue20/issue keywords keywordMagnetic phases/keyword keywordSpin glasses/keyword /keywords dates year2010/year /dates publisherElsevier/publisher electronic-resource-num10.1016/j.physb.2010.07.028/electronic-resource-num urls pdf-urls url internal-pdf://Banerjee et al. - 2010 - Magnetism in NiFeMo disordered alloys Experiment and theory.pdf /url /pdf-urls web-urls url http://linkinghub.elsevier.com/retrieve/pii/S0921452610007271 /url /web-urls /urls /record /records /xml Is there any xml parser that I can use with GTK2+? google says xml parsing can be done with php. What about C? Please help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: xml parse
Thanks Emmanuel and xiaohu I am new to GTK and C programming. Hence don't know things. Both of your reply helped me to find things out. Google said libxml2 is the standard way, where markup is not so standard to parse xml. I think I will stick to libxml2. On Sun, 2012-05-27 at 11:39 +0530, Rudra Banerjee wrote: Friends, I have an xml file. I want to search its Author and Year from GTK entry. The xml file looks like this: xml records record database name=My Collection.enl path=My Collection.enlMy Collection.enl/database ref-type name=Journal Article0/ref-type contributors authors authorBanerjee, Mitali/author authorBanerjee, Rudra/author authorMajumdar, a.K./author authorMookerjee, Abhijit/author authorSanyal, Biplab/author authorNigam, a.K./author /authors /contributors titles title Magnetism in NiFeMo disordered alloys: Experiment and theory /title secondary-titlePhysica B: Condensed Matter/secondary-title /titles periodical full-titlePhysica B: Condensed Matter/full-title /periodical pages4287-4293/pages volume405/volume issue20/issue keywords keywordMagnetic phases/keyword keywordSpin glasses/keyword /keywords dates year2010/year /dates publisherElsevier/publisher electronic-resource-num10.1016/j.physb.2010.07.028/electronic-resource-num urls pdf-urls url internal-pdf://Banerjee et al. - 2010 - Magnetism in NiFeMo disordered alloys Experiment and theory.pdf /url /pdf-urls web-urls url http://linkinghub.elsevier.com/retrieve/pii/S0921452610007271 /url /web-urls /urls /record /records /xml Is there any xml parser that I can use with GTK2+? google says xml parsing can be done with php. What about C? Please help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
compile gtk with libcurl
Friends, Please check the program: #include stdio.h #include gtk/gtk.h #include gdk/gdk.h #include curl/curl.h GtkWidget *Bar; size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream) { return fwrite(ptr, size, nmemb, stream); } size_t my_read_func(void *ptr, size_t size, size_t nmemb, FILE *stream) { return fread(ptr, size, nmemb, stream); } int my_progress_func(GtkWidget *bar, double t, /* dltotal */ double d, /* dlnow */ double ultotal, double ulnow) { /* printf(%d / %d (%g %%)\n, d, t, d*100.0/t);*/ gdk_threads_enter(); gtk_progress_set_value(GTK_PROGRESS(bar), d*100.0/t); gdk_threads_leave(); return 0; } void *my_thread(void *ptr) { CURL *curl; CURLcode res; FILE *outfile; gchar *url = ptr; curl = curl_easy_init(); if(curl) { outfile = fopen(test.curl, w); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func); curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar); res = curl_easy_perform(curl); fclose(outfile); /* always cleanup */ curl_easy_cleanup(curl); } return NULL; } int main(int argc, char **argv) { GtkWidget *Window, *Frame, *Frame2; GtkAdjustment *adj; /* Must initialize libcurl before any threads are started */ curl_global_init(CURL_GLOBAL_ALL); /* Init thread */ g_thread_init(NULL); gtk_init(argc, argv); Window = gtk_window_new(GTK_WINDOW_TOPLEVEL); Frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(Frame), GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(Window), Frame); Frame2 = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(Frame2), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(Frame), Frame2); gtk_container_set_border_width(GTK_CONTAINER(Frame2), 5); adj = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0); Bar = gtk_progress_bar_new_with_adjustment(adj); gtk_container_add(GTK_CONTAINER(Frame2), Bar); gtk_widget_show_all(Window); if (!g_thread_create(my_thread, argv[1], FALSE, NULL) != 0) g_warning(can't create the thread); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); return 0; } This is a program from libcurl. I posted in there forum and they said its better to post here. When I tried to compile it, I found the error: $ gcc curlgtk.c -o cpan `pkg-config --cflags gtk+-2.0` `pkg-config --libs libcurl gtk+-2.0` /usr/bin/ld: /tmp/ccZN7P8Q.o: undefined reference to symbol 'g_thread_init' /usr/bin/ld: note: 'g_thread_init' is defined in DSO /lib64/libgthread-2.0.so.0 so try adding it to the linker command line /lib64/libgthread-2.0.so.0: could not read symbols: Invalid operation I also tried the suggestion from https://bbs.archlinux.org/viewtopic.php?id=106212 and now the error is gcc curlgtk.c $(pkg-config --libs --cflags gtk+-2.0 librl) /usr/bin/ld: /tmp/ccfvzrCv.o: undefined reference to symbol 'g_thread_init' /usr/bin/ld: note: 'g_thread_init' is defined in DSO /lib64/libgthread-2.0.so.0 so try adding it to the linker command line /lib64/libgthread-2.0.so.0: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status Where I am going wrong? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: compile gtk with libcurl
Thanks ... its working! On Thu, 2012-05-24 at 19:19 +0200, David Nečas wrote: On Thu, May 24, 2012 at 10:37:01PM +0530, Rudra Banerjee wrote: $ gcc curlgtk.c -o cpan `pkg-config --cflags gtk+-2.0` `pkg-config --libs libcurl gtk+-2.0` /usr/bin/ld: /tmp/ccZN7P8Q.o: undefined reference to symbol 'g_thread_init' If you use gthread you must link with it. Simple. Use pkg-config --cflags --libs gtk+-2.0 gthread-2.0 libcurl Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gtk-app to search google scholar
Dear friends, I am trying to make a gtk application that will create a bibtex. The problem is I am a novice in C/gtk programming(this will be only my 2nd programme in gtk). To do that, First and foremost, I need to search google scholar from the code. I tried using lynx and failed. Can anyone kindly show me a simple code in C that can fetch data from google scholar with Import into bibtex entry on? Best and Regards, -- Rudra Banerjee If possible, plz. don't send me MsWord/PowerPoint mails. Why? See http://www.gnu.org/philosophy/no-word-attachments.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: probable gtk_window_present and pango help
David, Thanks for your suggestions and the sample code. I have managed to make it work. Just one more problem. If I have more then one button, say, in a nxn, it seems that if one callback is open, I have to close it to open a new one i.e. only one callback window will open at a time. One easy solution that I got is to declare nxn child_window, like GtkWidget *child_window1 = NULL; GtkWidget *child_window2 = NULL; and put an unique child_window to each button like button = gtk_button_new_with_label(main); g_signal_connect(button, clicked, G_CALLBACK(callback_it1), child_window1); gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 0, 1); gtk_widget_modify_bg( button, GTK_STATE_NORMAL, colorBlue ); button = gtk_button_new_with_label(main2); g_signal_connect(button, clicked, G_CALLBACK(callback_it2), child_window2); gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 0, 1); gtk_widget_modify_bg( button, GTK_STATE_NORMAL, colorBlue ); when this is very easy, but tedious and (IMHO) NOT the correct way of doing this thing. Can you please show how to get this done? On Fri, 2012-05-18 at 20:18 +0200, David Nečas wrote: On Fri, May 18, 2012 at 09:12:45PM +0530, Rudra Banerjee wrote: Here is a minimal example of a program, where if i click the button, a pop up window appears. I am posting both the call back function and the main routine (table.c). I am facing 2 problem. Unfortunately, you are facing much more problems. For start gtk_container_add(GTK_CONTAINER(window1), vbox1); is called with an unitialised variable window1 (i.e. no window1 is ever created). This leads to a CRITICAL message to console and/or crash. And if window1 existed then vbox1 would be packed into two different containers (window1 and window) which is not possible. So I'm ignoring that part altogether. The callback should look like void callback_it(GtkWidget *button, gpointer user_data) { ... } where in user_data the callback receives the last argument you passed to g_signal_connect(). It is rarely useful to pass a constant such as Call there. The callback is *not* another main() function; it should *not* call gtk_init() again, etc. Please read the signals section in the Gtk+ tutorial http://developer.gnome.org/gtk-tutorial/2.90/x159.html There are several other highly suspicious things: - redeclaration of global variables (such as window) inside a function; are you aware this creates a new local variable window that has nothing to do with the global one? - inclusion of .c files instead of separate compilation + linking them together - calling gtk_widget_show() on individual widgets and then again showing everything using gtk_widget_show_all() - not terminating the Gtk+ main loop when the main window is destroyed; this is usually the first thing to set up in a Gtk+ program, see http://developer.gnome.org/gtk-tutorial/2.90/c39.html#SEC-HELLOWORLD etc. 1) The problem is evry time I click the button main, a new window appears(obviously). What I want to achive is, if the window is already present, it should not open again; rather it should focus that window. I believe, this can be achived by gtk_window_present(may be I am wrong). But I don't know how to use it. You use it just by calling gtk_window_present() on the window object. To that meaningfully you need not only to keep the window object around but also get notified when the window is destroyed. Either by connecting to the destroy signal or, if you just want to set a pointer to NULL once it is gone, by using g_object_add_weak_pointer(). 2) In the callback function, I have C_1 and C_2. What I want to achive is Csub1/sub etc via pango(or any other). For simple things you can sometimes just use UTF-8. But generally, you need to use Pango markup. If the widget does not have function to set the markup it has a function to obtain the label widget so that you can use gtk_label_set_markup() on that. See the attached code with main problems fixed (and merged to one file). Please go through the Gtk+ tutorial farther that you perhaps have done. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
pango or any other way to format text
Can anybody please take some time to show me simple way of implementing pango formatting to get greek letters, subscripts and superscripts in gtk2+? A minimal(complete with headers) example will be very appriciated. -- Rudra JRF; SNBNCBS http://www.bose.res.in/~rudra A bus station is where a bus stops. A train station is where a train stops. On my desk I have a work station. Please, if possible, don't send me MS Word or PowerPoint attachments Why?See: http://www.gnu.org/philosophy/no-word-attachments.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
get integer/real number from gtk_entry_set_text
Friends, How can I convert gtk_entry_set_text to an integer/real number? Below is a minimal example. Please suggest. #include stdio.h #include gtk/gtk.h void enter_callback( GtkWidget *widget, GtkWidget *entry ) { gchar *entry_text; entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); printf(Entry contents: %s\n, entry_text); } int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *vbox, *hbox; GtkWidget *entry; GtkWidget *button; GtkWidget *check; GtkWidget *table; gtk_init (argc, argv); /* create a new window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW (window), GTK Entry); gtk_signal_connect(GTK_OBJECT (window), delete_event, (GtkSignalFunc) gtk_exit, NULL); /* CREATE TABLE */ table = gtk_table_new (5, 3, TRUE); gtk_container_add (GTK_CONTAINER (window), table); /* *CREATE ENTRY FOR ATOM 1 */ entry = gtk_entry_new_with_max_length (2); gtk_table_attach_defaults (GTK_TABLE (table), entry, 0, 1, 0, 1); gtk_signal_connect(GTK_OBJECT(entry), activate, GTK_SIGNAL_FUNC(enter_callback), entry); gtk_entry_set_text (GTK_ENTRY (entry), A); gtk_widget_show (entry); gtk_widget_show (button); gtk_widget_show (table); gtk_widget_show(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
Re: get integer/real number from gtk_entry_set_text
I tried putting #include stdlib.h and i=atoi(entry); printf(%d, i ); Now the complete program looks like: #include stdlib.h #include stdio.h #include gtk/gtk.h void enter_callback( GtkWidget *widget, GtkWidget *entry ) { gchar *entry_text; entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); printf(Entry contents: %s\n, entry_text); } int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *vbox, *hbox; GtkWidget *entry; GtkWidget *button; GtkWidget *check; GtkWidget *table; gtk_init (argc, argv); int i; double d; /* create a new window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW (window), GTK Entry); gtk_signal_connect(GTK_OBJECT (window), delete_event, (GtkSignalFunc) gtk_exit, NULL); /* CREATE TABLE */ table = gtk_table_new (5, 3, TRUE); gtk_container_add (GTK_CONTAINER (window), table); /* *CREATE ENTRY FOR ATOM 1 */ entry = gtk_entry_new_with_max_length (2); gtk_table_attach_defaults (GTK_TABLE (table), entry, 0, 1, 0, 1); gtk_signal_connect(GTK_OBJECT(entry), activate, GTK_SIGNAL_FUNC(enter_callback), entry); gtk_entry_set_text (GTK_ENTRY (entry), A); gtk_widget_show (entry); i=atoi(entry); printf(%d, i ); gtk_widget_show (button); gtk_widget_show (table); gtk_widget_show(window); gtk_main(); return(0); } but it still fails with segmentation fault. $gcc -g mini_ten.c -o ften `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` mini_ten.c: In function ‘enter_callback’: mini_ten.c:11:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default] mini_ten.c: In function ‘main’: mini_ten.c:51:1: warning: passing argument 1 of ‘atoi’ from incompatible pointer type [enabled by default] /usr/include/stdlib.h:148:12: note: expected ‘const char *’ but argument is of type ‘struct GtkWidget *’ $./ften Segmentation fault (core dumped) On Sat, 2012-05-12 at 21:01 -0400, Rudra Banerjee wrote: Friends, How can I convert gtk_entry_set_text to an integer/real number? Below is a minimal example. Please suggest. #include stdio.h #include gtk/gtk.h void enter_callback( GtkWidget *widget, GtkWidget *entry ) { gchar *entry_text; entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); printf(Entry contents: %s\n, entry_text); } int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *vbox, *hbox; GtkWidget *entry; GtkWidget *button; GtkWidget *check; GtkWidget *table; gtk_init (argc, argv); /* create a new window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW (window), GTK Entry); gtk_signal_connect(GTK_OBJECT (window), delete_event, (GtkSignalFunc) gtk_exit, NULL); /* CREATE TABLE */ table = gtk_table_new (5, 3, TRUE); gtk_container_add (GTK_CONTAINER (window), table); /* *CREATE ENTRY FOR ATOM 1 */ entry = gtk_entry_new_with_max_length (2); gtk_table_attach_defaults (GTK_TABLE (table), entry, 0, 1, 0, 1); gtk_signal_connect(GTK_OBJECT(entry), activate, GTK_SIGNAL_FUNC(enter_callback), entry); gtk_entry_set_text (GTK_ENTRY (entry), A); gtk_widget_show (entry); gtk_widget_show (button); gtk_widget_show (table); gtk_widget_show(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 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Table not visible
Dear friends, I am a newbie in GTK and also in C itself. I am trying to develop a table (thanks to awesome tutorials available). I am currently facing a problem. In the given code, its working fine. Posted is a minimal example I managed to generate. The problem is in line 88 and 89, either of table or menu is working. If I comment one line, other one is working. Where I went wrong? Please show. #include stdio.h #include stdlib.h #include gtk/gtk.h GtkWidget *window ; GtkWidget *vbox1 ;GtkWidget *menubar ;GtkWidget *filemenu ; GtkWidget *filemenu_menu ;GtkWidget *filenew ;GtkWidget *fileopen ;GtkWidget *filesave ; GtkWidget *separator_1 ;GtkWidget *filequit ;GtkWidget *editmenu ;GtkWidget *editmenu_menu ; GtkWidget *editcut ;GtkWidget *editcopy ;GtkWidget *editpaste ;GtkWidget *separator_2 ; GtkWidget *editselectall ;GtkWidget *editdeselect ;GtkWidget *helpmenu ; GtkWidget *helpmenu_menu ;GtkWidget *helphelp ;GtkWidget *helpabout ; GtkWidget *toolbar1 ;GtkToolItem *tooleditcut ;GtkToolItem *tooleditcopy ; GtkToolItem *tooleditpaste ;GtkToolItem *separator_3 ;GtkToolItem *tooleditselectall ; GtkWidget *label1 ;GtkWidget *hbox1 ;GtkWidget *button1 ;GtkWidget *button2 ; GtkAccelGroup *menuGroup;GtkWidget *window;GtkWidget *button;GtkWidget *table; void MessageBox (GtkWindow *parentWindow, char *messageValue) { GtkWidget *dialog; dialog = gtk_message_dialog_new (parentWindow, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, messageValue); gtk_window_set_title (GTK_WINDOW (dialog), Information); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } static void callback( GtkWidget *widget, gpointer data ) { g_print (Hello again - %s was pressed\n, (char *) data); } /* Stop the GTK+ main loop function. */ static void destroy_window (GtkWidget *window, gpointer data) { gtk_main_quit (); } /* Return FALSE to destroy the widget. By returning TRUE, you can cancel a delete-event. This can be used to confirm quitting the application. */ static gboolean delete_event_window (GtkWidget *window, GdkEvent *event, gpointer data) { return (FALSE); } static void helphelp_activated (GtkMenuItem *helphelp, GtkWindow *parentWindow) { MessageBox(parentWindow, Menu helphelp was clicked.); } static void helpabout_activated (GtkMenuItem *helpabout, GtkWindow *parentWindow) { MessageBox(parentWindow, Help Help Created.); } int main (int argc, char *argv[]) { gtk_init (argc, argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), Toolbar Test); gtk_window_set_default_size (GTK_WINDOW (window), 400, 200); // gtk_window_maximize (GTK_WINDOW (window)); /* Connect the main window to the destroy and delete-event signals. */ g_signal_connect (G_OBJECT (window), destroy, G_CALLBACK (destroy_window), NULL); g_signal_connect (G_OBJECT (window), delete_event, G_CALLBACK (delete_event_window), NULL); vbox1 = gtk_vbox_new (FALSE, 0); menubar = gtk_menu_bar_new (); gtk_box_pack_start (GTK_BOX (vbox1), menubar, FALSE, FALSE, 2); helpmenu = gtk_menu_item_new_with_label (Help); helpmenu_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (helpmenu), helpmenu_menu); gtk_menu_shell_append (GTK_MENU_SHELL (menubar), helpmenu); helphelp = gtk_image_menu_item_new_from_stock (GTK_STOCK_HELP, menuGroup); gtk_menu_shell_append (GTK_MENU_SHELL (helpmenu_menu), helphelp); g_signal_connect (G_OBJECT (helphelp), activate, G_CALLBACK (helphelp_activated), (gpointer) window); helpabout = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, menuGroup); gtk_menu_shell_append (GTK_MENU_SHELL (helpmenu_menu), helpabout); g_signal_connect (G_OBJECT (helpabout), activate, G_CALLBACK (helpabout_activated), (gpointer) window); /* Create a 2x2 table */ table = gtk_table_new (2, 2, TRUE); /* Put the table in the main window */ //gtk_container_add (GTK_CONTAINER (window), vbox1); gtk_container_add (GTK_CONTAINER (window), table); /* Color Scheme */ GdkColor colorBlue = { 0x, 3598, 57054, 61937 }; /* *CREATE FIRST ROW */ /* Create first button */ button = gtk_button_new_with_label (T1); /* When the button is clicked, we call the callback function * with a pointer to button 1 as its argument */ g_signal_connect (button, clicked, G_CALLBACK (callback), (gpointer) T1); /* Insert button 1 into the upper left quadrant of the table */ gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1); // without mouse hovering gtk_widget_modify_bg( button, GTK_STATE_NORMAL, colorBlue ); // with mouse hovering gtk_widget_modify_bg( button, GTK_STATE_PRELIGHT, colorBlue ); gtk_widget_show (button); /* Create second button */ button = gtk_button_new_with_label (T2); /* When the button is
GTK newbie help on G_CALLBACK
Dear Friends, I have taken a project (my own, not homework) to develop a table. I generally work with fortran, don't know C that much. What I want is a gtk clist to pop up when I press a button, via callback. The button widget in my code is /* Create first button */ button = gtk_button_new_with_label (B1); /* When the button is clicked, we call the callback function * with a pointer to button 1 as its argument */ g_signal_connect (button, clicked, G_CALLBACK (callback), (gpointer) B1); /* Insert button 1 into the upper left quadrant of the table */ gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1); gtk_widget_show (button); The definations are mostly based on http://developer.gnome.org/gtk-tutorial/2.24/x344.html What I want to do is callback to execute another gtk file, rather than what shown in the example. The source code of the pop up gtk file is: http://www.gtk.org/tutorial1.2/gtk_tut.html#toc11.10 Please help me. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list