Revision: 1572 http://svn.sourceforge.net/geany/?rev=1572&view=rev Author: eht16 Date: 2007-05-25 07:42:43 -0700 (Fri, 25 May 2007)
Log Message: ----------- Improve sensitivity of recent files sub menus.
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/src/callbacks.c trunk/src/callbacks.h trunk/src/geany.h trunk/src/interface.c trunk/src/main.c trunk/src/ui_utils.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/ChangeLog 2007-05-25 14:42:43 UTC (rev 1572) @@ -3,6 +3,9 @@ * data/filetype_extensions.conf, src/filetypes.c, tagmanager/sh.c: Add *.ash and *.bash as filetype entensions for filetype SH. Add ash and wish to the shebang patterns. + * geany.glade, src/callbacks.c, src/callbacks.h, src/geany.h, + src/interface.c, src/main.c, src/ui_utils.c: + Improve sensitivity of recent files sub menus.
2007-05-25 Nick Treleaven nick.treleaven@btinternet.com
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/geany.glade 2007-05-25 14:42:43 UTC (rev 1572) @@ -33,10 +33,11 @@ <property name="visible">True</property>
<child> - <widget class="GtkMenuItem" id="menuitem1"> + <widget class="GtkMenuItem" id="file1"> <property name="visible">True</property> <property name="label" translatable="yes">_File</property> <property name="use_underline">True</property> + <signal name="activate" handler="on_file1_activate" last_modification_time="Fri, 25 May 2007 13:28:40 GMT"/>
<child> <widget class="GtkMenu" id="menuitem1_menu">
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/src/callbacks.c 2007-05-25 14:42:43 UTC (rev 1572) @@ -286,6 +286,15 @@ }
+void +on_file1_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + gtk_widget_set_sensitive(app->recent_files_menuitem, + g_queue_get_length(app->recent_queue) > 0); +} + + // edit actions, c&p & co, from menu bar and from popup menu void on_edit1_activate (GtkMenuItem *menuitem, @@ -2216,3 +2225,4 @@ } }
+
Modified: trunk/src/callbacks.h =================================================================== --- trunk/src/callbacks.h 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/src/callbacks.h 2007-05-25 14:42:43 UTC (rev 1572) @@ -608,3 +608,7 @@ on_menu_toggle_all_additional_widgets1_activate (GtkMenuItem *menuitem, gpointer user_data); + +void +on_file1_activate (GtkMenuItem *menuitem, + gpointer user_data);
Modified: trunk/src/geany.h =================================================================== --- trunk/src/geany.h 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/src/geany.h 2007-05-25 14:42:43 UTC (rev 1572) @@ -177,6 +177,7 @@ GtkWidget *popup_menu; GtkWidget *toolbar_menu; GtkWidget *new_file_menu; + GtkWidget *recent_files_menuitem; GtkWidget *recent_files_menubar; GtkWidget *recent_files_toolbar; GtkWidget *menu_insert_include_item[2];
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/src/interface.c 2007-05-25 14:42:43 UTC (rev 1572) @@ -33,7 +33,7 @@ AtkObject *atko; GtkWidget *vbox1; GtkWidget *menubar1; - GtkWidget *menuitem1; + GtkWidget *file1; GtkWidget *menuitem1_menu; GtkWidget *menu_new1; GtkWidget *menu_new_with_template1; @@ -276,12 +276,12 @@ gtk_widget_show (menubar1); gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);
- menuitem1 = gtk_menu_item_new_with_mnemonic (_("_File")); - gtk_widget_show (menuitem1); - gtk_container_add (GTK_CONTAINER (menubar1), menuitem1); + file1 = gtk_menu_item_new_with_mnemonic (_("_File")); + gtk_widget_show (file1); + gtk_container_add (GTK_CONTAINER (menubar1), file1);
menuitem1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (file1), menuitem1_menu);
menu_new1 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group); gtk_widget_show (menu_new1); @@ -1252,6 +1252,9 @@ gtk_widget_show (statusbar); gtk_box_pack_start (GTK_BOX (hbox1), statusbar, TRUE, TRUE, 0);
+ g_signal_connect ((gpointer) file1, "activate", + G_CALLBACK (on_file1_activate), + NULL); g_signal_connect ((gpointer) menu_new1, "activate", G_CALLBACK (on_new1_activate), NULL); @@ -1567,7 +1570,7 @@ GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1"); GLADE_HOOKUP_OBJECT (window1, vbox1, "vbox1"); GLADE_HOOKUP_OBJECT (window1, menubar1, "menubar1"); - GLADE_HOOKUP_OBJECT (window1, menuitem1, "menuitem1"); + GLADE_HOOKUP_OBJECT (window1, file1, "file1"); GLADE_HOOKUP_OBJECT (window1, menuitem1_menu, "menuitem1_menu"); GLADE_HOOKUP_OBJECT (window1, menu_new1, "menu_new1"); GLADE_HOOKUP_OBJECT (window1, menu_new_with_template1, "menu_new_with_template1");
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/src/main.c 2007-05-25 14:42:43 UTC (rev 1572) @@ -221,11 +221,9 @@ (app->pref_editor_indention_mode != INDENT_NONE)); app->ignore_callback = FALSE;
- // connect the toolbar dropdown menus + // connect the toolbar dropdown menu for the new button gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON( lookup_widget(app->window, "menutoolbutton1")), app->new_file_menu); - gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON( - lookup_widget(app->window, "toolbutton9")), app->recent_files_toolbar);
// set the tab placements of the notebooks gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->notebook), app->tab_pos_editor); @@ -261,9 +259,10 @@ app->window = create_window1(); app->new_file_menu = gtk_menu_new(); app->recent_files_toolbar = gtk_menu_new(); + app->recent_files_menuitem = lookup_widget(app->window, "recent_files1"); app->recent_files_menubar = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "recent_files1")), - app->recent_files_menubar); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(app->recent_files_menuitem), + app->recent_files_menubar);
// store important pointers in the MyApp structure app->toolbar = lookup_widget(app->window, "toolbar1");
Modified: trunk/src/ui_utils.c =================================================================== --- trunk/src/ui_utils.c 2007-05-25 13:08:17 UTC (rev 1571) +++ trunk/src/ui_utils.c 2007-05-25 14:42:43 UTC (rev 1572) @@ -724,11 +724,10 @@ guint i; gchar *filename;
- if (g_queue_get_length(app->recent_queue) == 0) + if (g_queue_get_length(app->recent_queue) > 0) { - gtk_widget_set_sensitive(app->recent_files_menubar, FALSE); - gtk_widget_set_sensitive(app->recent_files_toolbar, FALSE); - return; + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON( + lookup_widget(app->window, "toolbutton9")), app->recent_files_toolbar); }
for (i = 0; i < MIN(app->mru_length, g_queue_get_length(app->recent_queue)); i++) @@ -852,20 +851,18 @@
static void update_recent_menu() { - GtkWidget *recent_files_item = lookup_widget(app->window, "recent_files1"); GtkWidget *tmp; + static GtkMenuToolButton *menu = NULL; gchar *filename; GList *children, *item;
- if (g_queue_get_length(app->recent_queue) == 0) + if (menu == NULL) + menu = GTK_MENU_TOOL_BUTTON(lookup_widget(app->window, "toolbutton9")); + + if (gtk_menu_tool_button_get_menu(menu) == NULL) { - gtk_widget_set_sensitive(recent_files_item, FALSE); - return; + gtk_menu_tool_button_set_menu(menu, app->recent_files_toolbar); } - else if (! GTK_WIDGET_SENSITIVE(recent_files_item)) - { - gtk_widget_set_sensitive(recent_files_item, TRUE); - }
// clean the MRU list before adding an item (menubar) children = gtk_container_get_children(GTK_CONTAINER(app->recent_files_menubar));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.