Kaydet (Commit) e8886e1a authored tarafından Enrico Tröger's avatar Enrico Tröger

made "make" build menu items sensitive for C header files


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@220 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst c8ca7268
......@@ -199,9 +199,9 @@ gint destroyapp(GtkWidget *widget, gpointer gdata)
scintilla_release_resources();
gtk_widget_destroy(app->window);
// kill explicitly since only one or none menu is shown at a time
if (GTK_IS_WIDGET(dialogs_build_menus.menu_c)) gtk_widget_destroy(dialogs_build_menus.menu_c);
if (GTK_IS_WIDGET(dialogs_build_menus.menu_misc)) gtk_widget_destroy(dialogs_build_menus.menu_misc);
if (GTK_IS_WIDGET(dialogs_build_menus.menu_tex)) gtk_widget_destroy(dialogs_build_menus.menu_tex);
if (GTK_IS_WIDGET(dialogs_build_menus.menu_c.menu)) gtk_widget_destroy(dialogs_build_menus.menu_c.menu);
if (GTK_IS_WIDGET(dialogs_build_menus.menu_misc.menu)) gtk_widget_destroy(dialogs_build_menus.menu_misc.menu);
if (GTK_IS_WIDGET(dialogs_build_menus.menu_tex.menu)) gtk_widget_destroy(dialogs_build_menus.menu_tex.menu);
/// destroy popup menus - FIXME TEST THIS CODE
if (GTK_IS_WIDGET(app->popup_menu)) gtk_widget_destroy(app->popup_menu);
......@@ -981,7 +981,7 @@ on_color_ok_button_clicked (GtkButton *button,
gtk_widget_hide(app->open_colorsel);
if (idx == -1 || ! doc_list[idx].is_valid) return;
gtk_color_selection_get_current_color(
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(app->open_colorsel)->colorsel), &color);
......
......@@ -252,7 +252,7 @@ gboolean dialogs_show_fifo_error(const gchar *text, ...)
GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, string);
ret = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if (ret == GTK_RESPONSE_YES) return TRUE;
else return FALSE;
}
......@@ -375,7 +375,7 @@ void dialogs_show_open_font(void)
gtk_window_set_destroy_with_parent(GTK_WINDOW(app->open_fontsel), TRUE);
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(app->open_fontsel), TRUE);
gtk_window_set_type_hint(GTK_WINDOW(app->open_fontsel), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_widget_show(GTK_FONT_SELECTION_DIALOG(app->open_fontsel)->apply_button);
g_signal_connect((gpointer) app->open_fontsel,
......@@ -552,7 +552,7 @@ void dialogs_show_color(void)
}
GtkWidget *dialogs_create_build_menu_gen(gboolean link, gboolean execute)
GtkWidget *dialogs_create_build_menu_gen(gboolean link, gboolean execute, build_menus_items *type)
{
GtkWidget *menu, *item, *image, *separator;
GtkAccelGroup *accel_group = gtk_accel_group_new();
......@@ -570,17 +570,19 @@ GtkWidget *dialogs_create_build_menu_gen(gboolean link, gboolean execute)
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);
type->item_compile = item;
if (link)
{ // build the code
app->build_menu_item_link = gtk_menu_item_new_with_label(_("Build"));
gtk_widget_show(app->build_menu_item_link);
gtk_container_add(GTK_CONTAINER(menu), app->build_menu_item_link);
gtk_tooltips_set_tip(tooltips, app->build_menu_item_link,
item = gtk_menu_item_new_with_label(_("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);
gtk_widget_add_accelerator(app->build_menu_item_link, "activate", accel_group, GDK_F9,
gtk_widget_add_accelerator(item, "activate", accel_group, GDK_F9,
(GdkModifierType) 0, GTK_ACCEL_VISIBLE);
g_signal_connect((gpointer) app->build_menu_item_link, "activate", G_CALLBACK(on_build_build_activate), NULL);
g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_build_activate), NULL);
type->item_link = item;
}
// build the code with make all
......@@ -610,6 +612,7 @@ GtkWidget *dialogs_create_build_menu_gen(gboolean link, gboolean execute)
gtk_widget_add_accelerator(item, "activate", accel_group, GDK_F5,
(GdkModifierType) 0, GTK_ACCEL_VISIBLE);
g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_execute_activate), NULL);
type->item_exec = item;
}
// separator
......@@ -636,7 +639,7 @@ GtkWidget *dialogs_create_build_menu_gen(gboolean link, gboolean execute)
}
GtkWidget *dialogs_create_build_menu_tex(void)
GtkWidget *dialogs_create_build_menu_tex(build_menus_items *type)
{
GtkWidget *menu, *item, *image, *separator;
GtkAccelGroup *accel_group = gtk_accel_group_new();
......@@ -1247,7 +1250,7 @@ void dialogs_show_file_properties(gint idx)
GtkRequisition *size;
#if defined(HAVE_SYS_STAT_H) && defined(HAVE_SYS_TYPES_H)
struct stat st;
off_t filesize;
off_t filesize;
mode_t mode;
#else
gint filesize = 0;
......@@ -1267,11 +1270,13 @@ void dialogs_show_file_properties(gint idx)
filesize = st.st_size;
mode = st.st_mode;
}
else
else
{
time_changed = g_strdup(_("unknown"));
time_modified = g_strdup(_("unknown"));
time_accessed = g_strdup(_("unknown"));
filesize = (off_t) 0;
mode = (mode_t) 0;
}
g_free(locale_filename);
#else
......@@ -1393,7 +1398,7 @@ void dialogs_show_file_properties(gint idx)
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
perm_table = gtk_table_new(4, 4, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(perm_table), 5);
gtk_table_set_col_spacings(GTK_TABLE(perm_table), 5);
......@@ -1496,7 +1501,7 @@ void dialogs_show_file_properties(gint idx)
check = gtk_check_button_new();
gtk_button_set_focus_on_click(GTK_BUTTON(check), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode & S_IROTH);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode & S_IROTH);
gtk_table_attach(GTK_TABLE(perm_table), check, 1, 2, 3, 4,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
......@@ -1521,7 +1526,7 @@ void dialogs_show_file_properties(gint idx)
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), perm_table);
// resize the dialog
......
......@@ -28,9 +28,18 @@
typedef struct
{
GtkWidget *menu_c;
GtkWidget *menu_tex;
GtkWidget *menu_misc;
GtkWidget *menu;
GtkWidget *item_compile;
GtkWidget *item_link;
GtkWidget *item_exec;
} build_menus_items;
build_menus_items dialogs_build_menus_items;
typedef struct
{
build_menus_items menu_c;
build_menus_items menu_tex;
build_menus_items menu_misc;
} build_menus;
build_menus dialogs_build_menus;
......@@ -66,9 +75,9 @@ void dialogs_show_word_count(void);
void dialogs_show_color(void);
GtkWidget *dialogs_create_build_menu_gen(gboolean link, gboolean execute);
GtkWidget *dialogs_create_build_menu_gen(gboolean link, gboolean execute, build_menus_items *type);
GtkWidget *dialogs_create_build_menu_tex(void);
GtkWidget *dialogs_create_build_menu_tex(build_menus_items *type);
void dialogs_show_make_target(void);
......
......@@ -232,13 +232,22 @@ static gint main_init(void)
#else
app->have_vte = FALSE;
#endif
app->ignore_global_tags = ignore_global_tags;
app->tm_workspace = tm_get_workspace();
app->recent_queue = g_queue_new();
app->opening_session_files = FALSE;
dialogs_build_menus.menu_c = NULL;
dialogs_build_menus.menu_tex = NULL;
dialogs_build_menus.menu_misc = NULL;
app->ignore_global_tags = ignore_global_tags;
app->tm_workspace = tm_get_workspace();
app->recent_queue = g_queue_new();
app->opening_session_files = FALSE;
dialogs_build_menus.menu_c.menu = NULL;
dialogs_build_menus.menu_c.item_compile = NULL;
dialogs_build_menus.menu_c.item_exec = NULL;
dialogs_build_menus.menu_c.item_link = NULL;
dialogs_build_menus.menu_tex.menu = NULL;
dialogs_build_menus.menu_tex.item_compile = NULL;
dialogs_build_menus.menu_tex.item_exec = NULL;
dialogs_build_menus.menu_tex.item_link = NULL;
dialogs_build_menus.menu_misc.menu = NULL;
dialogs_build_menus.menu_misc.item_compile = NULL;
dialogs_build_menus.menu_misc.item_exec = NULL;
dialogs_build_menus.menu_misc.item_link = NULL;
mkdir_result = utils_make_settings_dir();
if (mkdir_result != 0)
if (! dialogs_show_mkcfgdir_error(mkdir_result)) destroyapp_early();
......@@ -459,6 +468,7 @@ gint main(gint argc, gchar **argv)
document_init_doclist();
filetypes_init_types();
configuration_read_filetype_extensions();
gtk_window_set_icon(GTK_WINDOW(app->window), utils_new_pixbuf_from_inline(GEANY_IMAGE_LOGO, FALSE));
......
......@@ -236,7 +236,8 @@ GtkFileFilter *utils_create_file_filter(filetype *ft)
gtk_file_filter_set_name(new_filter, ft->title);
// (GEANY_FILETYPES_MAX_PATTERNS - 1) because the last field in pattern is NULL
for (i = 0; i < (GEANY_MAX_PATTERNS - 1) && ft->pattern[i]; i++)
//for (i = 0; i < (GEANY_MAX_PATTERNS - 1) && ft->pattern[i]; i++)
for (i = 0; ft->pattern[i]; i++)
{
gtk_file_filter_add_pattern(new_filter, ft->pattern[i]);
}
......@@ -985,11 +986,11 @@ gboolean utils_check_disk_status(gint idx, const gboolean force)
gchar *buff, *locale_filename;
if (idx == -1 || doc_list[idx].file_name == NULL) return FALSE;
t = time(NULL);
if (doc_list[idx].last_check > (t - 30)) return TRUE;
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
if (stat(locale_filename, &st) != 0) return TRUE;
......@@ -1332,7 +1333,7 @@ void utils_build_show_hide(gint idx)
static gboolean button_is_html = FALSE;
static GtkTooltips *tooltips = NULL;
if (doc_list[idx].file_name)
if (idx >= 0 && doc_list[idx].file_name)
{
ext = strrchr(doc_list[idx].file_name, '.');
}
......@@ -1363,43 +1364,57 @@ void utils_build_show_hide(gint idx)
case GEANY_FILETYPES_C: // intended fallthrough, C and C++ behave equal
case GEANY_FILETYPES_CPP:
{
if (dialogs_build_menus.menu_c == NULL)
if (dialogs_build_menus.menu_c.menu == NULL)
{
dialogs_build_menus.menu_c = dialogs_create_build_menu_gen(TRUE, TRUE);
g_object_ref((gpointer)dialogs_build_menus.menu_c); // to hold it after removing
dialogs_build_menus.menu_c.menu = dialogs_create_build_menu_gen(TRUE, TRUE, &dialogs_build_menus.menu_c);
g_object_ref((gpointer)dialogs_build_menus.menu_c.menu); // to hold it after removing
}
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), TRUE);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")),
dialogs_build_menus.menu_c);
gtk_widget_set_sensitive(app->compile_button, TRUE);
dialogs_build_menus.menu_c.menu);
if (is_header)
{
gtk_widget_set_sensitive(app->compile_button, FALSE);
gtk_widget_set_sensitive(dialogs_build_menus.menu_c.item_compile, FALSE);
gtk_widget_set_sensitive(dialogs_build_menus.menu_c.item_link, FALSE);
gtk_widget_set_sensitive(dialogs_build_menus.menu_c.item_exec, FALSE);
}
else
{
gtk_widget_set_sensitive(app->compile_button, TRUE);
gtk_widget_set_sensitive(dialogs_build_menus.menu_c.item_compile, TRUE);
gtk_widget_set_sensitive(dialogs_build_menus.menu_c.item_link, TRUE);
gtk_widget_set_sensitive(dialogs_build_menus.menu_c.item_exec, TRUE);
}
if (! is_header) break;
break;
}
case GEANY_FILETYPES_JAVA:
{
if (dialogs_build_menus.menu_misc == NULL)
if (dialogs_build_menus.menu_misc.menu == NULL)
{
dialogs_build_menus.menu_misc = dialogs_create_build_menu_gen(FALSE, TRUE);
g_object_ref((gpointer)dialogs_build_menus.menu_misc); // to hold it after removing
dialogs_build_menus.menu_misc.menu = dialogs_create_build_menu_gen(FALSE, TRUE, &dialogs_build_menus.menu_misc);
g_object_ref((gpointer)dialogs_build_menus.menu_misc.menu); // to hold it after removing
}
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), TRUE);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")),
dialogs_build_menus.menu_misc);
dialogs_build_menus.menu_misc.menu);
gtk_widget_set_sensitive(app->compile_button, TRUE);
if (! is_header) break;
break;
}
case GEANY_FILETYPES_XML: // intended fallthrough, HTML and XML behave equal
case GEANY_FILETYPES_PHP:
{
if (dialogs_build_menus.menu_misc == NULL)
if (dialogs_build_menus.menu_misc.menu == NULL)
{
dialogs_build_menus.menu_misc = dialogs_create_build_menu_gen(FALSE, TRUE);
g_object_ref((gpointer)dialogs_build_menus.menu_misc); // to hold it after removing
dialogs_build_menus.menu_misc.menu = dialogs_create_build_menu_gen(FALSE, TRUE, &dialogs_build_menus.menu_misc);
g_object_ref((gpointer)dialogs_build_menus.menu_misc.menu); // to hold it after removing
}
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")),
dialogs_build_menus.menu_misc);
dialogs_build_menus.menu_misc.menu);
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), TRUE);
gtk_widget_set_sensitive(app->compile_button, TRUE);
......@@ -1409,40 +1424,40 @@ void utils_build_show_hide(gint idx)
button_is_html = TRUE;
if (! is_header) break;
break;
}
case GEANY_FILETYPES_PASCAL:
{
if (dialogs_build_menus.menu_misc == NULL)
if (dialogs_build_menus.menu_misc.menu == NULL)
{
dialogs_build_menus.menu_misc = dialogs_create_build_menu_gen(FALSE, TRUE);
g_object_ref((gpointer)dialogs_build_menus.menu_misc); // to hold it after removing
dialogs_build_menus.menu_misc.menu = dialogs_create_build_menu_gen(FALSE, TRUE, &dialogs_build_menus.menu_misc);
g_object_ref((gpointer)dialogs_build_menus.menu_misc.menu); // to hold it after removing
}
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), TRUE);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")),
dialogs_build_menus.menu_misc);
dialogs_build_menus.menu_misc.menu);
gtk_widget_set_sensitive(app->compile_button, TRUE);
if (! is_header) break;
break;
}
case GEANY_FILETYPES_TEX:
{
if (dialogs_build_menus.menu_tex == NULL)
if (dialogs_build_menus.menu_tex.menu == NULL)
{
dialogs_build_menus.menu_tex = dialogs_create_build_menu_tex();
g_object_ref((gpointer)dialogs_build_menus.menu_tex); // to hold it after removing
dialogs_build_menus.menu_tex.menu = dialogs_create_build_menu_tex(&dialogs_build_menus.menu_tex);
g_object_ref((gpointer)dialogs_build_menus.menu_tex.menu); // to hold it after removing
}
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")),
dialogs_build_menus.menu_tex);
dialogs_build_menus.menu_tex.menu);
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), TRUE);
gtk_widget_set_sensitive(app->compile_button, TRUE);
if (! is_header) break;
break;
}
default:
{
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), FALSE);
gtk_widget_set_sensitive(app->compile_button, FALSE);
break;
}
}
#endif
......@@ -2137,7 +2152,7 @@ gchar *utils_get_current_file_dir(void)
{
gint cur_idx = document_get_cur_idx();
if (cur_idx >= 0) // if valid page found
if (cur_idx >= 0 && doc_list[cur_idx].is_valid) // if valid page found
{
// get current filename
const gchar *cur_fname = doc_list[cur_idx].file_name;
......@@ -2145,11 +2160,11 @@ gchar *utils_get_current_file_dir(void)
if (cur_fname != NULL)
{
// get folder part from current filename
return g_path_get_dirname(cur_fname); // returns "." if no path
return g_path_get_dirname(cur_fname); // returns "." if no path
}
}
return NULL; // no file open
return NULL; // no file open
}
......@@ -2159,6 +2174,7 @@ void utils_beep(void)
if (app->beep_on_errors) gdk_beep();
}
/* taken from busybox, thanks */
gchar *utils_make_human_readable_str(unsigned long long size, unsigned long block_size,
unsigned long display_unit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment