GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 02, 2014 2:31 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: GtkMenuToolButton not showing drop down menu in GTK+
PostPosted: Mon Jan 09, 2012 4:25 pm 
Offline
GTK+ Geek

Joined: Sun Apr 03, 2011 11:12 am
Posts: 63
Hello everyone, I have a gtkmenutoolitem and it isn't displaying the drop down menu. Here's the code

Code:
int main(int argc, char *argv[])
{
    GtkWidget *menubar, *file, *edit, *format, *tools, *filemenu, *editmenu,*formatmenu, *toolsmenu, *runmenu,*label1,*vbox,*hbox;
    GtkWidget *filenewmenu,*filenew, *new_proj, *new_file, *fileopenmenu, *open_proj, *open_file, *open, *save, *saveas, *savecopyas, *saveall, *saveasall, *restore, *newtab,*removetab, *recentfiles,*filemenu_separator,*filemenu_separator1,*exit;
    GtkWidget *addfilemenu,*addfile_existing, *addfile_new,*addfile_mainmenu,*addfile_main_existing, *addfile_main_new;
    GtkWidget *paste,*findandreplace,*find,*gotoline,*selectall,*editmenu_separator;
    GtkWidget *indentregion,*dedentregion,*commentout,*uncommentout,*striptrailingspaces;
    GtkWidget *gnome_terminal, *options, *pdb, *file_information,*class_browser, *proj_manager;
    GtkWidget *toolbar;
    GtkWidget *run,*runmodule;
    GtkToolItem *toolbar_new,*toolbar_open,*toolbar_save,*toolbar_cut,*toolbar_copy,*toolbar_paste,*toolbar_find,*toolbar_findandreplace,*toolbar_undo,*toolbar_redo,*toolbar_separator,*toolbar_saveas;
    GtkWidget *toolbar_new_menu,*toolbar_open_menu,*toolbar_new_file,*toolbar_new_proj,*toolbar_open_file,*toolbar_open_proj;
    GtkAccelGroup *group;
   
    gtk_init(&argc, &argv);
    toolbar = gtk_toolbar_new();
    gtk_box_pack_start(GTK_BOX(vbox),toolbar,FALSE,FALSE,0);
    gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar),TRUE);
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),GTK_TOOLBAR_ICONS);
   
    /*Toolbar*/
    toolbar_new = gtk_menu_tool_button_new_from_stock(GTK_STOCK_NEW); /*This is the GTKMENUTOOLBUTTON*/
    toolbar_open = gtk_menu_tool_button_new_from_stock(GTK_STOCK_OPEN); /*This is the GTKMENUTOOLBUTTON*/

    toolbar_save = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
    toolbar_saveas = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE_AS);
    toolbar_undo = gtk_tool_button_new_from_stock(GTK_STOCK_UNDO);
    toolbar_redo = gtk_tool_button_new_from_stock(GTK_STOCK_REDO);
    toolbar_cut = gtk_tool_button_new_from_stock(GTK_STOCK_CUT);
    toolbar_copy = gtk_tool_button_new_from_stock(GTK_STOCK_COPY);
    toolbar_paste = gtk_tool_button_new_from_stock(GTK_STOCK_PASTE);
    toolbar_find = gtk_tool_button_new_from_stock(GTK_STOCK_FIND);
    toolbar_findandreplace = gtk_tool_button_new_from_stock(GTK_STOCK_FIND_AND_REPLACE);
    toolbar_separator = gtk_separator_tool_item_new();   
   
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_new,0);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_open,1);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_save,2);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_saveas,3);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_separator,4);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_undo,5);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_redo,6);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_cut,7);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_copy,8);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_paste,9);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_find,10);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolbar_findandreplace,11);
   
    /*Create Menu Item of MenuToolButton*/
    toolbar_new_menu = gtk_menu_new();
    toolbar_open_menu = gtk_menu_new();
    toolbar_new_file = gtk_menu_item_new_with_label("Create New File");
    toolbar_new_proj = gtk_menu_item_new_with_label("Create New Project");
    toolbar_open_file = gtk_menu_item_new_with_label("Open File");
    toolbar_open_proj = gtk_menu_item_new_with_label("Open Project");   
    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_new),toolbar_new_menu);
    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_open),toolbar_open_menu);
   
    gtk_menu_shell_append(GTK_MENU_SHELL(toolbar_new_menu),toolbar_new_file);
    gtk_menu_shell_append(GTK_MENU_SHELL(toolbar_new_menu),toolbar_new_proj);
    gtk_menu_shell_append(GTK_MENU_SHELL(toolbar_open_menu),toolbar_open_file);
    gtk_menu_shell_append(GTK_MENU_SHELL(toolbar_open_menu),toolbar_open_proj);
   
    g_signal_connect(G_OBJECT(toolbar_undo),"clicked",G_CALLBACK(undo_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_redo),"clicked",G_CALLBACK(redo_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_cut),"clicked",G_CALLBACK(cut_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_paste),"clicked",G_CALLBACK(paste_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_copy),"clicked",G_CALLBACK(copy_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_find),"clicked",G_CALLBACK(find_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_findandreplace),"clicked",G_CALLBACK(findandreplace_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_save),"clicked",G_CALLBACK(save_activated),(gpointer)GTK_WINDOW(window));
    g_signal_connect(G_OBJECT(toolbar_saveas),"clicked",G_CALLBACK(saveas_activated),(gpointer)GTK_WINDOW(window));
    g_signal_connect(G_OBJECT(toolbar_open_file),"activate",G_CALLBACK(open_file_activated),(gpointer)GTK_WINDOW(window));
    g_signal_connect(G_OBJECT(toolbar_open_proj),"activate",G_CALLBACK(open_proj_activated),(gpointer)GTK_WINDOW(window));
    g_signal_connect(G_OBJECT(toolbar_new_file),"activate",G_CALLBACK(filenew_activated),NULL);
    g_signal_connect(G_OBJECT(toolbar_new_proj),"activate",G_CALLBACK(new_proj_activated),(gpointer)GTK_WINDOW(window));

    /****Other code lines****/

    gtk_widget_show_all(window);
    gtk_main();
   



This is the code which is showing problem. Actually, the drop down arrow is visible and when I click on it, the menu doesn't get displayed. Solve it pls..........


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group