Skip to content

Commit

Permalink
Merge pull request #1315 from techee/prjorg-fixes
Browse files Browse the repository at this point in the history
projectorganizer: Eliminate some compiler warnings
  • Loading branch information
techee authored Mar 17, 2024
2 parents ee7aac3 + 00f0f07 commit db2698c
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 55 deletions.
2 changes: 2 additions & 0 deletions projectorganizer/src/prjorg-menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef __PRJORG_MENU_H__
#define __PRJORG_MENU_H__

#include <glib.h>

void prjorg_menu_init(void);
void prjorg_menu_activate_menu_items(gboolean activate);
void prjorg_menu_cleanup(void);
Expand Down
77 changes: 49 additions & 28 deletions projectorganizer/src/prjorg-project.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,83 +655,100 @@ void prjorg_project_read_properties_tab(void)

GtkWidget *prjorg_project_add_properties_tab(GtkWidget *notebook)
{
GtkWidget *vbox, *hbox, *hbox1;
GtkWidget *table;
GtkWidget *vbox, *hbox, *hbox1, *ebox, *table_box;
GtkWidget *label;
gchar *str;
GtkSizeGroup *size_group;

e = g_new0(PropertyDialogElements, 1);

vbox = gtk_vbox_new(FALSE, 0);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

table = gtk_table_new(5, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table), 6);
gtk_table_set_col_spacings(GTK_TABLE(table), 12);
table_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
gtk_box_set_spacing(GTK_BOX(table_box), 6);

size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

label = gtk_label_new(_("Source patterns:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
e->source_patterns = gtk_entry_new();
ui_table_add_row(GTK_TABLE(table), 0, label, e->source_patterns, NULL);
ui_entry_add_clear_icon(GTK_ENTRY(e->source_patterns));
gtk_widget_set_tooltip_text(e->source_patterns,
_("Space separated list of patterns that are used to identify source files. "
"Used for header/source swapping."));
str = g_strjoinv(" ", prj_org->source_patterns);
gtk_entry_set_text(GTK_ENTRY(e->source_patterns), str);
g_free(str);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), e->source_patterns, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(table_box), ebox, TRUE, FALSE, 0);

label = gtk_label_new(_("Header patterns:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
e->header_patterns = gtk_entry_new();
ui_entry_add_clear_icon(GTK_ENTRY(e->header_patterns));
ui_table_add_row(GTK_TABLE(table), 1, label, e->header_patterns, NULL);
gtk_widget_set_tooltip_text(e->header_patterns,
_("Space separated list of patterns that are used to identify headers. "
"Used for header/source swapping."));
str = g_strjoinv(" ", prj_org->header_patterns);
gtk_entry_set_text(GTK_ENTRY(e->header_patterns), str);
g_free(str);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), e->header_patterns, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(table_box), ebox, TRUE, FALSE, 0);

label = gtk_label_new(_("Ignored file patterns:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
e->ignored_file_patterns = gtk_entry_new();
ui_entry_add_clear_icon(GTK_ENTRY(e->ignored_file_patterns));
ui_table_add_row(GTK_TABLE(table), 2, label, e->ignored_file_patterns, NULL);
gtk_widget_set_tooltip_text(e->ignored_file_patterns,
_("Space separated list of patterns that are used to identify files "
"that are not displayed in the project tree."));
str = g_strjoinv(" ", prj_org->ignored_file_patterns);
gtk_entry_set_text(GTK_ENTRY(e->ignored_file_patterns), str);
g_free(str);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), e->ignored_file_patterns, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(table_box), ebox, TRUE, FALSE, 0);

label = gtk_label_new(_("Ignored directory patterns:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
e->ignored_dirs_patterns = gtk_entry_new();
ui_entry_add_clear_icon(GTK_ENTRY(e->ignored_dirs_patterns));
ui_table_add_row(GTK_TABLE(table), 3, label, e->ignored_dirs_patterns, NULL);
gtk_widget_set_tooltip_text(e->ignored_dirs_patterns,
_("Space separated list of patterns that are used to identify directories "
"that are not scanned for source files."));
str = g_strjoinv(" ", prj_org->ignored_dirs_patterns);
gtk_entry_set_text(GTK_ENTRY(e->ignored_dirs_patterns), str);
g_free(str);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), e->ignored_dirs_patterns, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(table_box), ebox, TRUE, FALSE, 0);

gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 6);
gtk_box_pack_start(GTK_BOX(vbox), table_box, FALSE, FALSE, 6);

hbox1 = gtk_hbox_new(FALSE, 0);
hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new(_("The patterns above affect only sidebar and indexing and are not used in the Find in Files\n"
"dialog. You can further restrict the files belonging to the project by setting the\n"
"File Patterns under the Project tab (these are also used for the Find in Files dialog)."));
gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 12);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0);

hbox1 = gtk_hbox_new(FALSE, 0);
hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(label), _("<b>Various</b>"));
gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 12);

hbox1 = gtk_hbox_new(FALSE, 0);
hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
e->show_empty_dirs = gtk_check_button_new_with_label(_("Show empty directories in sidebar"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->show_empty_dirs), prj_org->show_empty_dirs);
gtk_widget_set_tooltip_text(e->show_empty_dirs,
Expand All @@ -741,12 +758,14 @@ GtkWidget *prjorg_project_add_properties_tab(GtkWidget *notebook)
gtk_box_pack_start(GTK_BOX(hbox1), e->show_empty_dirs, FALSE, FALSE, 12);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0);

table = gtk_table_new(1, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table), 6);
gtk_table_set_col_spacings(GTK_TABLE(table), 12);
table_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
gtk_box_set_spacing(GTK_BOX(table_box), 6);

size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

label = gtk_label_new(_("Index all project files:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
e->generate_tag_prefs = gtk_combo_box_text_new();
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(e->generate_tag_prefs), _("Auto (index if less than 1000 files)"));
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(e->generate_tag_prefs), _("Yes"));
Expand All @@ -755,16 +774,18 @@ GtkWidget *prjorg_project_add_properties_tab(GtkWidget *notebook)
gtk_widget_set_tooltip_text(e->generate_tag_prefs,
_("Generate symbol list for all project files instead of only for the currently opened files. "
"Might be slow for big projects."));
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), e->generate_tag_prefs, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(table_box), ebox, TRUE, FALSE, 0);

ui_table_add_row(GTK_TABLE(table), 1, label, e->generate_tag_prefs, NULL);

hbox1 = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), table, FALSE, FALSE, 12);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0);
hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(hbox1), table_box, FALSE, FALSE, 12);
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 6);

label = gtk_label_new("Project Organizer");

hbox = gtk_hbox_new(FALSE, 0);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 6);

gtk_notebook_append_page(GTK_NOTEBOOK(notebook), hbox, label);
Expand Down
2 changes: 2 additions & 0 deletions projectorganizer/src/prjorg-project.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef __PRJORG_PROJECT_H__
#define __PRJORG_PROJECT_H__

#include <gtk/gtk.h>

#define PRJORG_PATTERNS_SOURCE "*.c *.C *.cpp *.cxx *.c++ *.cc *.m"
#define PRJORG_PATTERNS_HEADER "*.h *.H *.hpp *.hxx *.h++ *.hh"
#define PRJORG_PATTERNS_IGNORED_DIRS ".* CVS"
Expand Down
50 changes: 23 additions & 27 deletions projectorganizer/src/prjorg-sidebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static gint show_dialog_find_file(gchar *utf8_path, gchar **pattern, gboolean *c
size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

label = gtk_label_new(_("Search for:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
s_fif_dialog.combo = gtk_combo_box_text_new_with_entry();
entry = gtk_bin_get_child(GTK_BIN(s_fif_dialog.combo));
Expand All @@ -147,29 +147,29 @@ static gint show_dialog_find_file(gchar *utf8_path, gchar **pattern, gboolean *c
ui_entry_add_clear_icon(GTK_ENTRY(entry));
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);

ebox = gtk_hbox_new(FALSE, 6);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), s_fif_dialog.combo, TRUE, TRUE, 0);

gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0);

label = gtk_label_new(_("Search inside:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
s_fif_dialog.dir_label = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(s_fif_dialog.dir_label), 0, 0.5);
gtk_label_set_xalign(GTK_LABEL(s_fif_dialog.dir_label), 0.0);

ebox = gtk_hbox_new(FALSE, 6);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), s_fif_dialog.dir_label, TRUE, TRUE, 0);

gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0);

s_fif_dialog.case_sensitive = gtk_check_button_new_with_mnemonic(_("C_ase sensitive"));
gtk_button_set_focus_on_click(GTK_BUTTON(s_fif_dialog.case_sensitive), FALSE);
gtk_widget_set_focus_on_click(s_fif_dialog.case_sensitive, FALSE);

s_fif_dialog.full_path = gtk_check_button_new_with_mnemonic(_("Search in full path"));
gtk_button_set_focus_on_click(GTK_BUTTON(s_fif_dialog.full_path), FALSE);
gtk_widget_set_focus_on_click(s_fif_dialog.full_path, FALSE);

gtk_box_pack_start(GTK_BOX(vbox), s_fif_dialog.case_sensitive, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), s_fif_dialog.full_path, TRUE, FALSE, 0);
Expand Down Expand Up @@ -346,7 +346,7 @@ static gchar *get_fallback_dir_of_selection(void)
{
locale_path = g_path_get_dirname(doc->real_path);

if (locale_path && locale_path == '.')
if (locale_path && *locale_path == '.')
{
g_free(locale_path);
locale_path = NULL;
Expand Down Expand Up @@ -382,7 +382,8 @@ void on_open_file_manager(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gp

if (locale_path)
{
gchar *command, *open_command;
const gchar *open_command;
gchar *command;

open_command = PRJORG_COMMAND_OPEN;
command = g_strconcat (open_command, " \"", locale_path, "\"", NULL);
Expand Down Expand Up @@ -726,7 +727,7 @@ static void create_dialog_find_tag(void)
size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);

label = gtk_label_new(_("Search for:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);

s_ft_dialog.combo = gtk_combo_box_text_new_with_entry();
Expand All @@ -738,13 +739,13 @@ static void create_dialog_find_tag(void)
ui_entry_add_clear_icon(GTK_ENTRY(entry));
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);

ebox = gtk_hbox_new(FALSE, 6);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), s_ft_dialog.combo, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0);

label = gtk_label_new(_("Match type:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);

s_ft_dialog.combo_match = gtk_combo_box_text_new();
Expand All @@ -754,28 +755,28 @@ static void create_dialog_find_tag(void)
gtk_combo_box_set_active(GTK_COMBO_BOX(s_ft_dialog.combo_match), 1);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), s_ft_dialog.combo_match);

ebox = gtk_hbox_new(FALSE, 6);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), s_ft_dialog.combo_match, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0);

label = gtk_label_new(_("Search inside:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
gtk_size_group_add_widget(size_group, label);
s_ft_dialog.dir_label = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(s_ft_dialog.dir_label), 0, 0.5);
gtk_label_set_xalign(GTK_LABEL(s_ft_dialog.dir_label), 0.0);

ebox = gtk_hbox_new(FALSE, 6);
ebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start(GTK_BOX(ebox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ebox), s_ft_dialog.dir_label, TRUE, TRUE, 0);

gtk_box_pack_start(GTK_BOX(vbox), ebox, TRUE, FALSE, 0);

s_ft_dialog.case_sensitive = gtk_check_button_new_with_mnemonic(_("C_ase sensitive"));
gtk_button_set_focus_on_click(GTK_BUTTON(s_ft_dialog.case_sensitive), FALSE);
gtk_widget_set_focus_on_click(s_ft_dialog.case_sensitive, FALSE);

s_ft_dialog.declaration = gtk_check_button_new_with_mnemonic(_("_Declaration"));
gtk_button_set_focus_on_click(GTK_BUTTON(s_ft_dialog.declaration), FALSE);
gtk_widget_set_focus_on_click(s_ft_dialog.declaration, FALSE);

g_object_unref(G_OBJECT(size_group)); /* auto destroy the size group */

Expand Down Expand Up @@ -1085,8 +1086,7 @@ static gboolean on_button_release(G_GNUC_UNUSED GtkWidget * widget, GdkEventButt

gtk_widget_set_sensitive(s_popup_menu.delete, delete_enabled);

gtk_menu_popup(GTK_MENU(s_popup_menu.widget), NULL, NULL, NULL, NULL,
event->button, event->time);
gtk_menu_popup_at_pointer(GTK_MENU(s_popup_menu.widget), (GdkEvent *)event);
return TRUE;
}

Expand Down Expand Up @@ -1207,7 +1207,7 @@ static void create_branch(gint level, GSList *leaf_list, GtkTreeIter *parent,
icon = NULL;
}
else
gtk_icon_info_free(icon_info);
g_object_unref(icon_info);
}
g_free(content_type);
}
Expand Down Expand Up @@ -1562,7 +1562,7 @@ gchar **prjorg_sidebar_get_expanded_paths(void)
(GtkTreeViewMappingFunc)on_map_expanded, expanded_paths);
g_ptr_array_add(expanded_paths, NULL);

return g_ptr_array_free(expanded_paths, FALSE);
return (gchar **)g_ptr_array_free(expanded_paths, FALSE);
}


Expand All @@ -1587,10 +1587,6 @@ void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths)

if (reload)
{
GtkTreeSelection *treesel;
GtkTreeIter iter;
GtkTreeModel *model;

expand_data->expanded_paths = expanded_paths != NULL ? expanded_paths : prjorg_sidebar_get_expanded_paths();
expand_data->selected_path = get_selected_path();

Expand Down Expand Up @@ -1658,7 +1654,7 @@ void prjorg_sidebar_init(void)
PangoFontDescription *pfd;
GList *focus_chain = NULL;

s_file_view_vbox = gtk_vbox_new(FALSE, 0);
s_file_view_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

/**** toolbar ****/

Expand Down
1 change: 1 addition & 0 deletions projectorganizer/src/prjorg-sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef __PRJORG_SIDEBAR_H__
#define __PRJORG_SIDEBAR_H__

#include <gtk/gtk.h>

void prjorg_sidebar_init(void);
void prjorg_sidebar_cleanup(void);
Expand Down
3 changes: 3 additions & 0 deletions projectorganizer/src/prjorg-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#ifndef __PRJORG_UTILS_H__
#define __PRJORG_UTILS_H__

#include <gtk/gtk.h>
#include <geanyplugin.h>

gchar *get_relative_path(const gchar *utf8_parent, const gchar *utf8_descendant);

gboolean patterns_match(GSList *patterns, const gchar *str);
Expand Down

0 comments on commit db2698c

Please sign in to comment.