Revision: 1038 http://svn.sourceforge.net/geany/?rev=1038&view=rev Author: ntrel Date: 2006-11-30 07:42:52 -0800 (Thu, 30 Nov 2006)
Log Message: ----------- Make all filetypes except LaTeX use the same build menu, disabling any items that don't apply for the current document. Move BuildMenuItems struct type to build.h.
Modified Paths: -------------- trunk/ChangeLog trunk/src/build.c trunk/src/build.h trunk/src/callbacks.c trunk/src/dialogs.c trunk/src/filetypes.c trunk/src/filetypes.h trunk/src/keybindings.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/ChangeLog 2006-11-30 15:42:52 UTC (rev 1038) @@ -3,6 +3,11 @@ * src/main.c: Disable open toolbutton recent files menu for now because on GTK+2.10 packing the recent files menu twice causes warnings. + * src/build.c, src/build.h, src/keybindings.c, src/callbacks.c, + src/filetypes.c, src/filetypes.h, src/dialogs.c: + Make all filetypes except LaTeX use the same build menu, disabling + any items that don't apply for the current document. + Move BuildMenuItems struct type to build.h.
2006-11-29 Nick Treleaven nick.treleaven@btinternet.com
Modified: trunk/src/build.c =================================================================== --- trunk/src/build.c 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/src/build.c 2006-11-30 15:42:52 UTC (rev 1038) @@ -62,7 +62,12 @@ LATEX_CMD_VIEW_PDF };
+static BuildMenuItems default_menu_items = + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +static BuildMenuItems latex_menu_items = + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data); static gboolean build_create_shellscript(const gint idx, const gchar *fname, const gchar *cmd, gboolean autoclose); @@ -82,6 +87,11 @@ { g_free(build_info.dir); g_free(build_info.custom_target); + + if (default_menu_items.menu != NULL && GTK_IS_WIDGET(default_menu_items.menu)) + gtk_widget_destroy(default_menu_items.menu); + if (latex_menu_items.menu != NULL && GTK_IS_WIDGET(latex_menu_items.menu)) + gtk_widget_destroy(latex_menu_items.menu); }
@@ -793,49 +803,40 @@ gtk_widget_add_accelerator(menuitem, "activate", accel_group, \ keys[(gkey)]->key, keys[(gkey)]->mods, GTK_ACCEL_VISIBLE)
-static GtkWidget *create_build_menu_gen(gint idx) +static void create_build_menu_gen(BuildMenuItems *menu_items) { GtkWidget *menu, *item = NULL, *image, *separator; GtkAccelGroup *accel_group = gtk_accel_group_new(); GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips")); - filetype *ft = doc_list[idx].file_type;
menu = gtk_menu_new();
#ifndef G_OS_WIN32 - if (ft->menu_items->can_compile) - { - // compile the code - item = gtk_image_menu_item_new_with_mnemonic(_("_Compile")); - gtk_widget_show(item); - gtk_container_add(GTK_CONTAINER(menu), item); - gtk_tooltips_set_tip(tooltips, item, _("Compiles the current file"), NULL); - GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_COMPILE, item); - image = gtk_image_new_from_stock("gtk-convert", GTK_ICON_SIZE_MENU); - gtk_widget_show(image); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); - g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_compile_activate), NULL); - ft->menu_items->item_compile = item; - } + // compile the code + item = gtk_image_menu_item_new_with_mnemonic(_("_Compile")); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + gtk_tooltips_set_tip(tooltips, item, _("Compiles the current file"), NULL); + GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_COMPILE, item); + image = gtk_image_new_from_stock("gtk-convert", GTK_ICON_SIZE_MENU); + gtk_widget_show(image); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); + g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_compile_activate), NULL); + menu_items->item_compile = item;
- if (ft->menu_items->can_link) - { // build the code - item = gtk_image_menu_item_new_with_mnemonic(_("_Build")); - gtk_widget_show(item); - gtk_container_add(GTK_CONTAINER(menu), item); - gtk_tooltips_set_tip(tooltips, item, - _("Builds the current file (generate an executable file)"), NULL); - GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_LINK, item); - g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_build_activate), NULL); - ft->menu_items->item_link = item; - } + // build the code + item = gtk_image_menu_item_new_with_mnemonic(_("_Build")); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + gtk_tooltips_set_tip(tooltips, item, + _("Builds the current file (generate an executable file)"), NULL); + GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_LINK, item); + g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_build_activate), NULL); + menu_items->item_link = item;
- if (item != NULL) - { - item = gtk_separator_menu_item_new(); - gtk_widget_show(item); - gtk_container_add(GTK_CONTAINER(menu), item); - } + item = gtk_separator_menu_item_new(); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item);
// build the code with make all item = gtk_image_menu_item_new_with_mnemonic(_("_Make all")); @@ -846,7 +847,7 @@ GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_MAKE, item); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(GBO_MAKE_ALL)); - ft->menu_items->item_make_all = item; + menu_items->item_make_all = item;
// build the code with make custom item = gtk_image_menu_item_new_with_mnemonic(_("Make custom _target")); @@ -857,7 +858,7 @@ "make tool and the specified target"), NULL); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(GBO_MAKE_CUSTOM)); - ft->menu_items->item_make_custom = item; + menu_items->item_make_custom = item;
// build the code with make object item = gtk_image_menu_item_new_with_mnemonic(_("Make _object")); @@ -868,56 +869,51 @@ "make tool"), NULL); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(GBO_MAKE_OBJECT)); - ft->menu_items->item_make_object = item; + menu_items->item_make_object = item; #endif
- if (ft->menu_items->can_exec) - { // execute the code - item = gtk_separator_menu_item_new(); - gtk_widget_show(item); - gtk_container_add(GTK_CONTAINER(menu), item); + item = gtk_separator_menu_item_new(); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item);
- item = gtk_image_menu_item_new_from_stock("gtk-execute", accel_group); - gtk_widget_show(item); - gtk_container_add(GTK_CONTAINER(menu), item); - gtk_tooltips_set_tip(tooltips, item, _("Run or view the current file"), NULL); - GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_RUN, item); - g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_execute_activate), NULL); - ft->menu_items->item_exec = item; - } + // execute the code + item = gtk_image_menu_item_new_from_stock("gtk-execute", accel_group); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + gtk_tooltips_set_tip(tooltips, item, _("Run or view the current file"), NULL); + GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_RUN, item); + g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_execute_activate), NULL); + menu_items->item_exec = item;
+ separator = gtk_separator_menu_item_new(); + gtk_widget_show(separator); + gtk_container_add(GTK_CONTAINER(menu), separator); + gtk_widget_set_sensitive(separator, FALSE); + // arguments - if (ft->menu_items->can_compile || ft->menu_items->can_link || ft->menu_items->can_exec) - { - // separator - separator = gtk_separator_menu_item_new(); - gtk_widget_show(separator); - gtk_container_add(GTK_CONTAINER(menu), separator); - gtk_widget_set_sensitive(separator, FALSE); + item = gtk_image_menu_item_new_with_mnemonic(_("_Set Includes and Arguments")); + gtk_widget_show(item); + GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_OPTIONS, item); + gtk_container_add(GTK_CONTAINER(menu), item); + gtk_tooltips_set_tip(tooltips, item, + _("Sets the includes and library paths for the compiler and " + "the program arguments for execution"), NULL); + image = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_MENU); + gtk_widget_show(image); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); + g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_arguments_activate), NULL); + menu_items->item_set_args = item;
- item = gtk_image_menu_item_new_with_mnemonic(_("_Set Includes and Arguments")); - gtk_widget_show(item); - GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_OPTIONS, item); - gtk_container_add(GTK_CONTAINER(menu), item); - gtk_tooltips_set_tip(tooltips, item, - _("Sets the includes and library paths for the compiler and " - "the program arguments for execution"), NULL); - image = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_MENU); - gtk_widget_show(image); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); - g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_arguments_activate), NULL); - } - - return menu; + menu_items->menu = menu; + g_object_ref((gpointer)menu_items->menu); // to hold it after removing }
-static GtkWidget *create_build_menu_tex() +static void create_build_menu_tex(BuildMenuItems *menu_items) { GtkWidget *menu, *item, *image, *separator; GtkAccelGroup *accel_group = gtk_accel_group_new(); GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips")); - filetype *ft = filetypes[GEANY_FILETYPES_LATEX];
menu = gtk_menu_new();
@@ -935,7 +931,7 @@ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_tex_activate), GINT_TO_POINTER(LATEX_CMD_TO_DVI)); - ft->menu_items->item_compile = item; + menu_items->item_compile = item;
// PDF item = gtk_image_menu_item_new_with_mnemonic(_("LaTeX -> PDF")); @@ -950,7 +946,7 @@ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_tex_activate), GINT_TO_POINTER(LATEX_CMD_TO_PDF)); - ft->menu_items->item_link = item; + menu_items->item_link = item;
if (item != NULL) { @@ -968,7 +964,7 @@ GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_MAKE, item); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(GBO_MAKE_ALL)); - ft->menu_items->item_make_all = item; + menu_items->item_make_all = item;
// build the code with make custom item = gtk_image_menu_item_new_with_mnemonic(_("Make custom _target")); @@ -979,7 +975,7 @@ "make tool and the specified target"), NULL); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(GBO_MAKE_CUSTOM)); - ft->menu_items->item_make_custom = item; + menu_items->item_make_custom = item;
if (item != NULL) { @@ -1003,7 +999,7 @@ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_execute_activate), GINT_TO_POINTER(LATEX_CMD_VIEW_DVI)); - ft->menu_items->item_exec = item; + menu_items->item_exec = item;
// PDF view item = gtk_image_menu_item_new_with_mnemonic(_("View PDF file")); @@ -1018,7 +1014,7 @@ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_execute_activate), GINT_TO_POINTER(LATEX_CMD_VIEW_PDF)); - ft->menu_items->item_exec2 = item; + menu_items->item_exec2 = item;
// separator separator = gtk_separator_menu_item_new(); @@ -1039,11 +1035,13 @@ gtk_widget_show(image); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); g_signal_connect((gpointer) item, "activate", - G_CALLBACK(on_build_arguments_activate), ft); + G_CALLBACK(on_build_arguments_activate), filetypes[GEANY_FILETYPES_LATEX]); + menu_items->item_set_args = item;
gtk_window_add_accel_group(GTK_WINDOW(app->window), accel_group);
- return menu; + menu_items->menu = menu; + g_object_ref((gpointer)menu_items->menu); // to hold it after removing }
@@ -1059,10 +1057,13 @@ }
+/* Call this whenever build menu items need to be enabled/disabled. + * Uses current document (if there is one) when idx == -1 */ void build_menu_update(gint idx) { filetype *ft; - gboolean have_path, can_build, can_make; + gboolean have_path, can_build, can_make, can_run, can_set_args; + BuildMenuItems *menu_items;
if (idx == -1) idx = document_get_cur_idx(); @@ -1080,6 +1081,7 @@ gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), TRUE);
ft = doc_list[idx].file_type; + g_return_if_fail(ft != NULL);
#ifdef G_OS_WIN32 // disable compile and link under Windows until it is implemented @@ -1087,16 +1089,11 @@ ft->menu_items->can_link = FALSE; #endif
- if (ft->menu_items->menu == NULL) - { - ft->menu_items->menu = (ft->id == GEANY_FILETYPES_LATEX) ? - create_build_menu_tex() : create_build_menu_gen(idx); - g_object_ref((gpointer)ft->menu_items->menu); // to hold it after removing - } + menu_items = build_get_menu_items(ft); /* Note: don't remove the submenu first because it can now cause an X hang if * the menu is already open when called from build_exit_cb(). */ gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")), - ft->menu_items->menu); + menu_items->menu);
have_path = (doc_list[idx].file_name != NULL);
@@ -1108,31 +1105,36 @@ else can_build = can_make;
- if (ft->menu_items->can_compile) - gtk_widget_set_sensitive(ft->menu_items->item_compile, can_build); - if (ft->menu_items->can_link) - gtk_widget_set_sensitive(ft->menu_items->item_link, can_build); - if (ft->menu_items->item_make_all) - gtk_widget_set_sensitive(ft->menu_items->item_make_all, can_make); - if (ft->menu_items->item_make_custom) - gtk_widget_set_sensitive(ft->menu_items->item_make_custom, can_make); - if (ft->menu_items->item_make_object) - gtk_widget_set_sensitive(ft->menu_items->item_make_object, can_make); - if (ft->menu_items->can_exec) - { - gboolean can_run = have_path && run_info.pid <= 1; + if (menu_items->item_compile) + gtk_widget_set_sensitive(menu_items->item_compile, can_build && ft->actions->can_compile); + if (menu_items->item_link) + gtk_widget_set_sensitive(menu_items->item_link, can_build && ft->actions->can_link); + if (menu_items->item_make_all) + gtk_widget_set_sensitive(menu_items->item_make_all, can_make); + if (menu_items->item_make_custom) + gtk_widget_set_sensitive(menu_items->item_make_custom, can_make); + if (menu_items->item_make_object) + gtk_widget_set_sensitive(menu_items->item_make_object, can_make);
- /* can_run only applies item_exec2 - * item_exec is enabled for both run and stop commands */ - if (ft->menu_items->item_exec) - gtk_widget_set_sensitive(ft->menu_items->item_exec, have_path); - if (ft->menu_items->item_exec2) - gtk_widget_set_sensitive(ft->menu_items->item_exec2, can_run); - } + can_run = have_path && run_info.pid <= 1; + /* can_run only applies item_exec2 + * item_exec is enabled for both run and stop commands */ + if (menu_items->item_exec) + gtk_widget_set_sensitive(menu_items->item_exec, have_path && ft->actions->can_exec); + if (menu_items->item_exec2) + gtk_widget_set_sensitive(menu_items->item_exec2, can_run && ft->actions->can_exec);
- gtk_widget_set_sensitive(app->compile_button, can_build && ft->menu_items->can_compile); - gtk_widget_set_sensitive(app->run_button, have_path && ft->menu_items->can_exec); + can_set_args = + ((ft->actions->can_compile || + ft->actions->can_link || + ft->actions->can_exec) && + FILETYPE_ID(ft) != GEANY_FILETYPES_ALL); + if (menu_items->item_set_args) + gtk_widget_set_sensitive(menu_items->item_set_args, can_set_args);
+ gtk_widget_set_sensitive(app->compile_button, can_build && ft->actions->can_compile); + gtk_widget_set_sensitive(app->run_button, have_path && ft->actions->can_exec); + // show the stop command if a program is running, otherwise show run command set_stop_button(run_info.pid > 1); } @@ -1143,7 +1145,7 @@ { GtkStockItem sitem; GtkWidget *menuitem = - filetypes[run_info.file_type_id]->menu_items->item_exec; + build_get_menu_items(filetypes[run_info.file_type_id])->item_exec;
if (stop && utils_str_equal( gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(app->run_button)), "gtk-stop")) return; @@ -1192,6 +1194,27 @@ }
+// Creates the relevant build menu if necessary. +BuildMenuItems *build_get_menu_items(const filetype *ft) +{ + BuildMenuItems *items; + + if (FILETYPE_ID(ft) == GEANY_FILETYPES_LATEX) + { + items = &latex_menu_items; + if (items->menu == NULL) + create_build_menu_tex(items); + } + else + { + items = &default_menu_items; + if (items->menu == NULL) + create_build_menu_gen(items); + } + return items; +} + + void on_build_compile_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -1405,3 +1428,4 @@ g_free(first); }
+
Modified: trunk/src/build.h =================================================================== --- trunk/src/build.h 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/src/build.h 2006-11-30 15:42:52 UTC (rev 1038) @@ -24,6 +24,8 @@ #ifndef GEANY_BUILD_H #define GEANY_BUILD_H 1
+#include "filetypes.h" + typedef enum // Geany Build Options { GBO_COMPILE, @@ -44,7 +46,21 @@
extern BuildInfo build_info;
+typedef struct +{ + GtkWidget *menu; + GtkWidget *item_compile; + GtkWidget *item_link; + GtkWidget *item_make_all; + GtkWidget *item_make_custom; + GtkWidget *item_make_object; + GtkWidget *item_exec; + GtkWidget *item_exec2; + GtkWidget *item_set_args; +} BuildMenuItems;
+ + void build_finalize();
GPid build_make_file(gint idx, gint build_opts); @@ -61,7 +77,9 @@
void build_menu_update(gint idx);
+BuildMenuItems *build_get_menu_items(const filetype *ft);
+ void on_build_compile_activate (GtkMenuItem *menuitem, gpointer user_data);
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/src/callbacks.c 2006-11-30 15:42:52 UTC (rev 1038) @@ -1685,7 +1685,7 @@ const gchar *newstr; struct build_programs *programs = ft->programs;
- if (ft->menu_items->can_compile) + if (ft->actions->can_compile) { newstr = gtk_entry_get_text( GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "includes_entry1"))); @@ -1696,7 +1696,7 @@ programs->modified = TRUE; } } - if (ft->menu_items->can_link) + if (ft->actions->can_link) { newstr = gtk_entry_get_text( GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "includes_entry2"))); @@ -1707,7 +1707,7 @@ programs->modified = TRUE; } } - if (ft->menu_items->can_exec) + if (ft->actions->can_exec) { newstr = gtk_entry_get_text( GTK_ENTRY(lookup_widget(GTK_WIDGET(dialog), "includes_entry3")));
Modified: trunk/src/dialogs.c =================================================================== --- trunk/src/dialogs.c 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/src/dialogs.c 2006-11-30 15:42:52 UTC (rev 1038) @@ -716,7 +716,7 @@ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_container_add(GTK_CONTAINER(vbox), label);
- if (ft->menu_items->can_compile || ft->menu_items->can_link || ft->menu_items->can_exec) + if (ft->actions->can_compile || ft->actions->can_link || ft->actions->can_exec) { GtkWidget *align, *frame; gchar *frame_title = g_strconcat(ft->title, _(" commands"), NULL); @@ -732,7 +732,7 @@ }
// include-args - if (ft->menu_items->can_compile) + if (ft->actions->can_compile) { label = gtk_label_new(_("Compile:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); @@ -753,7 +753,7 @@ }
// lib-args - if (ft->menu_items->can_link) + if (ft->actions->can_link) { label = gtk_label_new(_("Build:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); @@ -774,7 +774,7 @@ }
// program-args - if (ft->menu_items->can_exec) + if (ft->actions->can_exec) { label = gtk_label_new(_("Execute:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/src/filetypes.c 2006-11-30 15:42:52 UTC (rev 1038) @@ -710,7 +710,7 @@ { ftype->programs = g_new0(struct build_programs, 1);
- ftype->menu_items = g_new0(struct build_menu_items, 1); + ftype->actions = g_new0(struct build_actions, 1); }
@@ -864,10 +864,7 @@ g_free(filetypes[i]->programs->run_cmd); g_free(filetypes[i]->programs->run_cmd2); g_free(filetypes[i]->programs); - if (filetypes[i]->menu_items->menu != NULL && - GTK_IS_WIDGET(filetypes[i]->menu_items->menu)) - gtk_widget_destroy(filetypes[i]->menu_items->menu); - g_free(filetypes[i]->menu_items); + g_free(filetypes[i]->actions);
g_strfreev(filetypes[i]->pattern); g_free(filetypes[i]); @@ -918,7 +915,7 @@ if (result != NULL) { filetypes[ft]->programs->compiler = result; - filetypes[ft]->menu_items->can_compile = TRUE; + filetypes[ft]->actions->can_compile = TRUE; }
result = g_key_file_get_string(configh, "build_settings", "linker", NULL); @@ -926,7 +923,7 @@ if (result != NULL) { filetypes[ft]->programs->linker = result; - filetypes[ft]->menu_items->can_link = TRUE; + filetypes[ft]->actions->can_link = TRUE; }
result = g_key_file_get_string(configh, "build_settings", "run_cmd", NULL); @@ -934,7 +931,7 @@ if (result != NULL) { filetypes[ft]->programs->run_cmd = result; - filetypes[ft]->menu_items->can_exec = TRUE; + filetypes[ft]->actions->can_exec = TRUE; }
result = g_key_file_get_string(configh, "build_settings", "run_cmd2", NULL); @@ -942,7 +939,7 @@ if (result != NULL) { filetypes[ft]->programs->run_cmd2 = result; - filetypes[ft]->menu_items->can_exec = TRUE; + filetypes[ft]->actions->can_exec = TRUE; } }
Modified: trunk/src/filetypes.h =================================================================== --- trunk/src/filetypes.h 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/src/filetypes.h 2006-11-30 15:42:52 UTC (rev 1038) @@ -69,19 +69,11 @@ (((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_ALL)
-struct build_menu_items +struct build_actions { - GtkWidget *menu; - GtkWidget *item_compile; - GtkWidget *item_link; - GtkWidget *item_exec; - GtkWidget *item_exec2; - GtkWidget *item_make_all; - GtkWidget *item_make_custom; - GtkWidget *item_make_object; - gboolean can_compile; - gboolean can_link; - gboolean can_exec; + gboolean can_compile:1; + gboolean can_link:1; + gboolean can_exec:1; };
struct build_programs @@ -108,8 +100,8 @@ gchar *comment_open; gchar *comment_close; gboolean comment_use_indent; - struct build_programs *programs; - struct build_menu_items *menu_items; + struct build_programs *programs; + struct build_actions *actions; void (*style_func_ptr) (ScintillaObject*); } filetype;
Modified: trunk/src/keybindings.c =================================================================== --- trunk/src/keybindings.c 2006-11-30 14:40:32 UTC (rev 1037) +++ trunk/src/keybindings.c 2006-11-30 15:42:52 UTC (rev 1038) @@ -75,7 +75,6 @@ static void cb_func_menu_foldall(guint key_id); static void cb_func_menu_unfoldall(guint key_id); static void cb_func_build_action(guint key_id); -static void cb_func_build_options(guint key_id); static void cb_func_reloadtaglist(guint key_id); static void cb_func_switch_editor(guint key_id); static void cb_func_switch_scribble(guint key_id); @@ -172,7 +171,7 @@ GDK_F5, 0, "build_run", _("Run")); keys[GEANY_KEYS_BUILD_RUN2] = fill(cb_func_build_action, 0, 0, "build_run2", _("Run (alternative command)")); - keys[GEANY_KEYS_BUILD_OPTIONS] = fill(cb_func_build_options, + keys[GEANY_KEYS_BUILD_OPTIONS] = fill(cb_func_build_action, 0, 0, "build_options", _("Build options")); keys[GEANY_KEYS_RELOADTAGLIST] = fill(cb_func_reloadtaglist, GDK_r, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "reloadtaglist", _("Reload symbol list")); @@ -570,42 +569,48 @@ gint idx = document_get_cur_idx(); GtkWidget *item; filetype *ft; + BuildMenuItems *menu_items;
if (! DOC_IDX_VALID(idx)) return;
ft = doc_list[idx].file_type; - if (! ft || ! ft->menu_items) return; + if (! ft) return; + menu_items = build_get_menu_items(ft);
switch (key_id) { case GEANY_KEYS_BUILD_COMPILE: - item = ft->menu_items->item_compile; + item = menu_items->item_compile; break;
case GEANY_KEYS_BUILD_LINK: - item = ft->menu_items->item_link; + item = menu_items->item_link; break;
case GEANY_KEYS_BUILD_MAKE: - item = ft->menu_items->item_make_all; + item = menu_items->item_make_all; break;
case GEANY_KEYS_BUILD_MAKEOWNTARGET: - item = ft->menu_items->item_make_custom; + item = menu_items->item_make_custom; break;
case GEANY_KEYS_BUILD_MAKEOBJECT: - item = ft->menu_items->item_make_object; + item = menu_items->item_make_object; break;
case GEANY_KEYS_BUILD_RUN: - item = ft->menu_items->item_exec; + item = menu_items->item_exec; break;
case GEANY_KEYS_BUILD_RUN2: - item = ft->menu_items->item_exec2; + item = menu_items->item_exec2; break;
+ case GEANY_KEYS_BUILD_OPTIONS: + item = menu_items->item_set_args; + break; + default: item = NULL; } @@ -613,24 +618,6 @@ gtk_menu_item_activate(GTK_MENU_ITEM(item)); }
-static void cb_func_build_options(G_GNUC_UNUSED guint key_id) -{ - gint idx = document_get_cur_idx(); - document *doc; - filetype *ft; - - if (! DOC_IDX_VALID(idx)) return; - doc = &doc_list[idx]; - ft = doc->file_type; - if (! ft || ! ft->menu_items) return; - if ((ft->menu_items->can_compile || - ft->menu_items->can_link || - ft->menu_items->can_exec) && - (doc->file_name != NULL || - FILETYPE_ID(ft) != GEANY_FILETYPES_ALL)) - on_build_arguments_activate(NULL, ft); -} - static void cb_func_reloadtaglist(G_GNUC_UNUSED guint key_id) { gint idx = document_get_cur_idx();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.