Skip to content

Commit

Permalink
Remove redundant toolbar-specific callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
b4n committed Jun 24, 2014
1 parent 517bf5f commit a398b08
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 75 deletions.
52 changes: 2 additions & 50 deletions src/callbacks.c
Expand Up @@ -74,7 +74,6 @@


/* prototypes of Glade-only callback to let the compiler know they really are meant to be exported */
G_MODULE_EXPORT void on_new1_activate(GtkMenuItem *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_info1_activate(GtkMenuItem *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_change_font1_activate(GtkMenuItem *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_crlf_activate(GtkCheckMenuItem *menuitem, gpointer user_data);
Expand Down Expand Up @@ -460,13 +459,6 @@ G_MODULE_EXPORT void on_open1_activate(GtkMenuItem *menuitem, gpointer user_data
}


/* quit toolbar button */
void on_toolbutton_quit_clicked(GtkAction *action, gpointer user_data)
{
on_exit_clicked(NULL, NULL);
}


/* reload file */
G_MODULE_EXPORT void on_toolbutton_reload_clicked(GtkAction *action, gpointer user_data)
{
Expand All @@ -484,27 +476,6 @@ G_MODULE_EXPORT void on_change_font1_activate(GtkMenuItem *menuitem, gpointer us
}


/* new file */
void on_toolbutton_new_clicked(GtkAction *action, gpointer user_data)
{
document_new_file(NULL, NULL, NULL);
}


/* open file */
void on_toolbutton_open_clicked(GtkAction *action, gpointer user_data)
{
dialogs_show_open_file();
}


/* save file */
void on_toolbutton_save_clicked(GtkAction *action, gpointer user_data)
{
on_save1_activate(NULL, user_data);
}


/* store text, clear search flags so we can use Search->Find Next/Previous */
static void setup_find(const gchar *text, gboolean backwards)
{
Expand Down Expand Up @@ -610,25 +581,6 @@ G_MODULE_EXPORT void on_normal_size1_activate(GtkMenuItem *menuitem, gpointer us
}


/* close tab */
void on_toolbutton_close_clicked(GtkAction *action, gpointer user_data)
{
on_close1_activate(NULL, NULL);
}


void on_toolbutton_close_all_clicked(GtkAction *action, gpointer user_data)
{
on_close_all1_activate(NULL, NULL);
}


void on_toolbutton_preferences_clicked(GtkAction *action, gpointer user_data)
{
on_preferences1_activate(NULL, NULL);
}


static gboolean delayed_check_disk_status(gpointer data)
{
document_check_disk_status(data, FALSE);
Expand Down Expand Up @@ -1827,13 +1779,13 @@ G_MODULE_EXPORT void on_menu_toggle_all_additional_widgets1_activate(GtkMenuItem
}


void on_forward_activate(GtkMenuItem *menuitem, gpointer user_data)
void on_toolbutton_forward_activate(GtkAction *menuitem, gpointer user_data)
{
navqueue_go_forward();
}


void on_back_activate(GtkMenuItem *menuitem, gpointer user_data)
void on_toolbutton_back_activate(GtkAction *menuitem, gpointer user_data)
{
navqueue_go_back();
}
Expand Down
20 changes: 4 additions & 16 deletions src/callbacks.h
Expand Up @@ -30,6 +30,8 @@ extern gboolean ignore_callback;

gboolean on_exit_clicked(GtkWidget *widget, gpointer gdata);

G_MODULE_EXPORT void on_new1_activate(GtkMenuItem *menuitem, gpointer user_data);

G_MODULE_EXPORT void on_save1_activate(GtkMenuItem *menuitem, gpointer user_data);

G_MODULE_EXPORT void on_save_as1_activate(GtkMenuItem *menuitem, gpointer user_data);
Expand All @@ -38,10 +40,6 @@ G_MODULE_EXPORT void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data

G_MODULE_EXPORT void on_open1_activate(GtkMenuItem *menuitem, gpointer user_data);

void on_toolbutton_close_clicked(GtkAction *action, gpointer user_data);

void on_toolbutton_close_all_clicked(GtkAction *action, gpointer user_data);

G_MODULE_EXPORT void on_save_all1_activate(GtkMenuItem *menuitem, gpointer user_data);

G_MODULE_EXPORT void on_close1_activate(GtkMenuItem *menuitem, gpointer user_data);
Expand Down Expand Up @@ -98,16 +96,6 @@ G_MODULE_EXPORT void on_replace1_activate(GtkMenuItem *menuitem, gpointer user_d

G_MODULE_EXPORT void on_find_in_files1_activate(GtkMenuItem *menuitem, gpointer user_data);

void on_toolbutton_new_clicked(GtkAction *action, gpointer user_data);

void on_toolbutton_open_clicked(GtkAction *action, gpointer user_data);

void on_toolbutton_save_clicked(GtkAction *action, gpointer user_data);

void on_toolbutton_quit_clicked(GtkAction *action, gpointer user_data);

void on_toolbutton_preferences_clicked(GtkAction *action, gpointer user_data);

G_MODULE_EXPORT void on_toolbutton_reload_clicked(GtkAction *action, gpointer user_data);

G_MODULE_EXPORT void on_go_to_line_activate(GtkMenuItem *menuitem, gpointer user_data);
Expand Down Expand Up @@ -168,9 +156,9 @@ G_MODULE_EXPORT void on_context_action1_activate(GtkMenuItem *menuitem, gpointer

G_MODULE_EXPORT void on_menu_toggle_all_additional_widgets1_activate(GtkMenuItem *menuitem, gpointer user_data);

void on_back_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_toolbutton_back_activate(GtkAction *action, gpointer user_data);

void on_forward_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_toolbutton_forward_activate(GtkAction *action, gpointer user_data);

gboolean on_motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer user_data);

Expand Down
18 changes: 9 additions & 9 deletions src/toolbar.c
Expand Up @@ -55,20 +55,20 @@ static GSList *plugin_items = NULL;
* Fields: name, stock_id, label, accelerator, tooltip, callback */
static const GtkActionEntry ui_entries[] = {
/* custom actions defined in toolbar_init(): "New", "Open", "SearchEntry", "GotoEntry", "Build" */
{ "Save", GTK_STOCK_SAVE, NULL, NULL, N_("Save the current file"), G_CALLBACK(on_toolbutton_save_clicked) },
{ "Save", GTK_STOCK_SAVE, NULL, NULL, N_("Save the current file"), G_CALLBACK(on_save1_activate) },
{ "SaveAs", GTK_STOCK_SAVE_AS, NULL, NULL, N_("Save as"), G_CALLBACK(on_save_as1_activate) },
{ "SaveAll", GEANY_STOCK_SAVE_ALL, NULL, NULL, N_("Save all open files"), G_CALLBACK(on_save_all1_activate) },
{ "Reload", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL, N_("Reload the current file from disk"), G_CALLBACK(on_toolbutton_reload_clicked) },
{ "Close", GTK_STOCK_CLOSE, NULL, NULL, N_("Close the current file"), G_CALLBACK(on_toolbutton_close_clicked) },
{ "CloseAll", GEANY_STOCK_CLOSE_ALL, NULL, NULL, N_("Close all open files"), G_CALLBACK(on_toolbutton_close_all_clicked) },
{ "Close", GTK_STOCK_CLOSE, NULL, NULL, N_("Close the current file"), G_CALLBACK(on_close1_activate) },
{ "CloseAll", GEANY_STOCK_CLOSE_ALL, NULL, NULL, N_("Close all open files"), G_CALLBACK(on_close_all1_activate) },
{ "Cut", GTK_STOCK_CUT, NULL, NULL, N_("Cut the current selection"), G_CALLBACK(on_cut1_activate) },
{ "Copy", GTK_STOCK_COPY, NULL, NULL, N_("Copy the current selection"), G_CALLBACK(on_copy1_activate) },
{ "Paste", GTK_STOCK_PASTE, NULL, NULL, N_("Paste the contents of the clipboard"), G_CALLBACK(on_paste1_activate) },
{ "Delete", GTK_STOCK_DELETE, NULL, NULL, N_("Delete the current selection"), G_CALLBACK(on_delete1_activate) },
{ "Undo", GTK_STOCK_UNDO, NULL, NULL, N_("Undo the last modification"), G_CALLBACK(on_undo1_activate) },
{ "Redo", GTK_STOCK_REDO, NULL, NULL, N_("Redo the last modification"), G_CALLBACK(on_redo1_activate) },
{ "NavBack", GTK_STOCK_GO_BACK, NULL, NULL, N_("Navigate back a location"), G_CALLBACK(on_back_activate) },
{ "NavFor", GTK_STOCK_GO_FORWARD, NULL, NULL, N_("Navigate forward a location"), G_CALLBACK(on_forward_activate) },
{ "NavBack", GTK_STOCK_GO_BACK, NULL, NULL, N_("Navigate back a location"), G_CALLBACK(on_toolbutton_back_activate) },
{ "NavFor", GTK_STOCK_GO_FORWARD, NULL, NULL, N_("Navigate forward a location"), G_CALLBACK(on_toolbutton_forward_activate) },
{ "Compile", GTK_STOCK_CONVERT, N_("Compile"), NULL, N_("Compile the current file"), G_CALLBACK(on_toolbutton_compile_clicked) },
{ "Run", GTK_STOCK_EXECUTE, NULL, NULL, N_("Run or view the current file"), G_CALLBACK(on_toolbutton_run_clicked) },
{ "Color", GTK_STOCK_SELECT_COLOR, N_("Color Chooser"), NULL, N_("Open a color chooser dialog, to interactively pick colors from a palette"), G_CALLBACK(on_show_color_chooser1_activate) },
Expand All @@ -78,8 +78,8 @@ static const GtkActionEntry ui_entries[] = {
{ "Indent", GTK_STOCK_INDENT, NULL, NULL, N_("Increase indentation"), G_CALLBACK(on_menu_increase_indent1_activate) },
{ "Search", GTK_STOCK_FIND, NULL, NULL, N_("Find the entered text in the current file"), G_CALLBACK(on_toolbutton_search_clicked) },
{ "Goto", GTK_STOCK_JUMP_TO, NULL, NULL, N_("Jump to the entered line number"), G_CALLBACK(on_toolbutton_goto_clicked) },
{ "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, N_("Show the preferences dialog"), G_CALLBACK(on_toolbutton_preferences_clicked) },
{ "Quit", GTK_STOCK_QUIT, NULL, NULL, N_("Quit Geany"), G_CALLBACK(on_toolbutton_quit_clicked) },
{ "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, N_("Show the preferences dialog"), G_CALLBACK(on_preferences1_activate) },
{ "Quit", GTK_STOCK_QUIT, NULL, NULL, N_("Quit Geany"), G_CALLBACK(on_quit1_activate) },
{ "Print", GTK_STOCK_PRINT, NULL, NULL, N_("Print document"), G_CALLBACK(on_print1_activate) },
{ "Replace", GTK_STOCK_FIND_AND_REPLACE, NULL, NULL, N_("Replace text in the current document"), G_CALLBACK(on_replace1_activate) }
};
Expand Down Expand Up @@ -360,15 +360,15 @@ GtkWidget *toolbar_init(void)
_("Create a new file"),
_("Create a new file from a template"),
GTK_STOCK_NEW);
g_signal_connect(action_new, "button-clicked", G_CALLBACK(on_toolbutton_new_clicked), NULL);
g_signal_connect(action_new, "button-clicked", G_CALLBACK(on_new1_activate), NULL);
gtk_action_group_add_action(group, action_new);

action_open = geany_menu_button_action_new(
"Open", NULL,
_("Open an existing file"),
_("Open a recent file"),
GTK_STOCK_OPEN);
g_signal_connect(action_open, "button-clicked", G_CALLBACK(on_toolbutton_open_clicked), NULL);
g_signal_connect(action_open, "button-clicked", G_CALLBACK(on_open1_activate), NULL);
gtk_action_group_add_action(group, action_open);

action_build = geany_menu_button_action_new(
Expand Down

0 comments on commit a398b08

Please sign in to comment.