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

Instantly reload (i.e. rebuild) the toolbar when ui_toolbar.xml is saved within Geany.

Refactor some related code.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3874 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 385ce9f9
2009-06-20 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* data/ui_toolbar.xml, doc/geany.txt, src/build.c,
src/geanymenubuttonaction.c, src/geanymenubuttonaction.h, src/main.c,
src/plugins.c, src/templates.c, src/toolbar.c, src/toolbar.h,
src/ui_utils.c, src/ui_utils.h:
Instantly reload (i.e. rebuild) the toolbar when ui_toolbar.xml is
saved within Geany.
Refactor some related code.
2009-06-18 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/highlighting.c, README.Packagers, HACKING:
......
......@@ -3,10 +3,10 @@ This is Geany's toolbar UI definition.
The DTD can be found at http://library.gnome.org/devel/gtk/stable/GtkUIManager.html#GtkUIManager.description.
You can re-order all items and freely add and remove available actions.
You cannot add new actions which are not listed below.
You cannot add new actions which are not listed in the documentation.
Everything you add or change must be inside the /ui/toolbar/ path.
For changes to take effect, you need to restart Geany.
For changes to take effect, simply save this file within Geany or restart Geany.
A list of available actions can be found in the documentation included with Geany or
at http://www.geany.org/manual/current/index.html#customizing-the-toolbar.
......
......@@ -3534,11 +3534,11 @@ you wish and add or remove additional separators.
This file must be valid XML, otherwise the global toolbar UI definition
will be used instead.
Your changes are applied once you save the file.
.. note::
(1) You cannot add new actions which are not listed below.
(2) Everything you add or change must be inside the /ui/toolbar/ path.
(3) After you finish editing the file, you need to restart Geany
for changes to take effect.
Available toolbar elements
......
......@@ -94,10 +94,10 @@ static BuildMenuItems latex_menu_items =
static struct
{
GtkWidget *run_button;
GtkWidget *compile_button;
GtkWidget *build_button;
GtkAction *run_action;
GtkAction *compile_action;
GtkAction *build_action;
GtkWidget *toolmenu;
GtkWidget *toolitem_build;
GtkWidget *toolitem_make_all;
......@@ -130,7 +130,7 @@ static void show_build_result_message(gboolean failure);
static void process_build_output_line(const gchar *line, gint color);
void build_finalize()
void build_finalize(void)
{
g_free(build_info.dir);
g_free(build_info.custom_target);
......@@ -139,6 +139,8 @@ void build_finalize()
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);
g_object_unref(widgets.toolmenu);
}
......@@ -1627,9 +1629,9 @@ void build_menu_update(GeanyDocument *doc)
{
gtk_widget_set_sensitive(menubar_build_menu, FALSE);
gtk_menu_item_remove_submenu(GTK_MENU_ITEM(menubar_build_menu));
ui_widget_set_sensitive(widgets.compile_button, FALSE);
ui_widget_set_sensitive(widgets.build_button, FALSE);
ui_widget_set_sensitive(widgets.run_button, FALSE);
gtk_action_set_sensitive(widgets.compile_action, FALSE);
gtk_action_set_sensitive(widgets.build_action, FALSE);
gtk_action_set_sensitive(widgets.run_action, FALSE);
return;
}
else
......@@ -1703,10 +1705,10 @@ void build_menu_update(GeanyDocument *doc)
if (widgets.toolitem_set_args != NULL)
gtk_widget_set_sensitive(widgets.toolitem_set_args, can_set_args);
ui_widget_set_sensitive(widgets.compile_button,
gtk_action_set_sensitive(widgets.compile_action,
can_build && ft->actions->can_compile && NZV(ft->programs->compiler));
ui_widget_set_sensitive(widgets.build_button, can_make);
ui_widget_set_sensitive(widgets.run_button, can_run || can_stop);
gtk_action_set_sensitive(widgets.build_action, can_make);
gtk_action_set_sensitive(widgets.run_action, can_run || can_stop);
/* show the stop command if a program is running, otherwise show run command */
set_stop_button(can_stop);
......@@ -1725,21 +1727,20 @@ void build_menu_update(GeanyDocument *doc)
static void set_stop_button(gboolean stop)
{
GtkStockItem sitem;
GtkToolButton *run_button;
GtkWidget *menuitem =
build_get_menu_items(run_info.file_type_id)->item_exec;
if (widgets.run_button == NULL)
run_button = GTK_TOOL_BUTTON(toolbar_get_widget_by_name("Run"));
if (stop && utils_str_equal(gtk_tool_button_get_stock_id(run_button), "gtk-stop"))
return;
if (! stop && utils_str_equal(gtk_tool_button_get_stock_id(run_button), "gtk-execute"))
return;
if (stop && utils_str_equal(
gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(widgets.run_button)), "gtk-stop")) return;
if (! stop && utils_str_equal(
gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(widgets.run_button)), "gtk-execute")) return;
/* use the run button also as stop button */
if (stop)
{
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(widgets.run_button), "gtk-stop");
gtk_tool_button_set_stock_id(run_button, "gtk-stop");
if (menuitem != NULL)
{
......@@ -1752,7 +1753,7 @@ static void set_stop_button(gboolean stop)
}
else
{
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(widgets.run_button), "gtk-execute");
gtk_tool_button_set_stock_id(run_button, "gtk-execute");
if (menuitem != NULL)
{
......@@ -2095,16 +2096,15 @@ on_build_previous_error (GtkMenuItem *menuitem,
}
void build_init()
void build_init(void)
{
GtkWidget *item;
GtkWidget *toolmenu;
widgets.build_action = toolbar_get_action_by_name("Build");
toolmenu = geany_menu_button_action_get_menu(GEANY_MENU_BUTTON_ACTION(widgets.build_action));
/* create the toolbar Build item sub menu */
toolmenu = gtk_menu_new();
g_object_ref(toolmenu);
if (toolmenu != NULL)
{
/* build the code */
item = ui_image_menu_item_new(GEANY_STOCK_BUILD, _("_Build"));
gtk_widget_show(item);
......@@ -2150,11 +2150,15 @@ void build_init()
gtk_container_add(GTK_CONTAINER(toolmenu), item);
g_signal_connect(item, "activate", G_CALLBACK(on_build_arguments_activate), NULL);
widgets.toolitem_set_args = item;
}
widgets.compile_button = toolbar_get_widget_by_name("Compile");
widgets.run_button = toolbar_get_widget_by_name("Run");
widgets.build_button = toolbar_get_widget_by_name("Build");
/* get toolbar action pointers */
widgets.build_action = toolbar_get_action_by_name("Build");
widgets.compile_action = toolbar_get_action_by_name("Compile");
widgets.run_action = toolbar_get_action_by_name("Run");
widgets.toolmenu = toolmenu;
/* set the submenu to the toolbar item */
geany_menu_button_action_set_menu(GEANY_MENU_BUTTON_ACTION(widgets.build_action), toolmenu);
}
......
......@@ -26,6 +26,7 @@
#include "geany.h"
#include "support.h"
#include "utils.h"
#include "geanymenubuttonaction.h"
......@@ -37,9 +38,7 @@ typedef struct _GeanyMenubuttonActionPrivate GeanyMenubuttonActionPrivate;
struct _GeanyMenubuttonActionPrivate
{
GtkWidget *button;
GtkWidget *menu;
gboolean menu_added;
};
enum
......@@ -64,48 +63,12 @@ static void geany_menu_button_action_finalize(GObject *object)
}
static void menu_filled_cb(GtkContainer *container, GtkWidget *widget, gpointer data)
{
GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(data);
if (! priv->menu_added)
{
gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(priv->button), priv->menu);
priv->menu_added = TRUE;
}
}
static void geany_menu_button_action_connect_proxy(GtkAction *action, GtkWidget *widget)
{
GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action);
/* add the menu to the menu button once it got items ("add" from GtkContainer) */
g_signal_connect(priv->menu, "add", G_CALLBACK(menu_filled_cb), action);
GTK_ACTION_CLASS(geany_menu_button_action_parent_class)->connect_proxy(action, widget);
}
static void delegate_button_activated(GtkAction *action)
{
g_signal_emit(action, signals[BUTTON_CLICKED], 0);
}
static GtkWidget *geany_menu_button_action_create_tool_item(GtkAction *action)
{
GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action);
priv->menu = gtk_menu_new();
g_object_ref(priv->menu);
gtk_widget_show(priv->menu);
priv->button = g_object_new(GTK_TYPE_MENU_TOOL_BUTTON, NULL);
return priv->button;
}
static void geany_menu_button_action_class_init(GeanyMenubuttonActionClass *klass)
{
GtkActionClass *action_class = GTK_ACTION_CLASS(klass);
......@@ -114,8 +77,6 @@ static void geany_menu_button_action_class_init(GeanyMenubuttonActionClass *klas
g_object_class->finalize = geany_menu_button_action_finalize;
action_class->activate = delegate_button_activated;
action_class->connect_proxy = geany_menu_button_action_connect_proxy;
action_class->create_tool_item = geany_menu_button_action_create_tool_item;
action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
g_type_class_add_private(klass, sizeof(GeanyMenubuttonActionPrivate));
......@@ -133,11 +94,7 @@ static void geany_menu_button_action_class_init(GeanyMenubuttonActionClass *klas
static void geany_menu_button_action_init(GeanyMenubuttonAction *action)
{
GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action);
priv->menu = NULL;
priv->button = NULL;
priv->menu_added = FALSE;
/* nothing to do */
}
......@@ -167,3 +124,22 @@ GtkWidget *geany_menu_button_action_get_menu(GeanyMenubuttonAction *action)
return priv->menu;
}
void geany_menu_button_action_set_menu(GeanyMenubuttonAction *action, GtkWidget *menu)
{
GeanyMenubuttonActionPrivate *priv;
GSList *l;
g_return_if_fail(action != NULL);
g_return_if_fail(menu != NULL);
priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action);
priv->menu = menu;
foreach_slist(l, gtk_action_get_proxies(GTK_ACTION(action)))
{
gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(l->data), priv->menu);
}
}
......@@ -55,6 +55,8 @@ GtkAction* geany_menu_button_action_new (const gchar *name,
const gchar *stock_id);
GtkWidget* geany_menu_button_action_get_menu (GeanyMenubuttonAction *action);
void geany_menu_button_action_set_menu (GeanyMenubuttonAction *action, GtkWidget *menu);
G_END_DECLS
#endif /* __GEANY_MENU_BUTTON_ACTION_H__ */
......@@ -192,37 +192,7 @@ static void apply_settings(void)
}
ui_sidebar_show_hide();
/* sets the icon style of the toolbar */
switch (toolbar_prefs.icon_style)
{
case GTK_TOOLBAR_BOTH:
{
/*gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "images_and_text1")), TRUE);*/
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(ui_widgets.toolbar_menu, "images_and_text2")), TRUE);
break;
}
case GTK_TOOLBAR_ICONS:
{
/*gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "images_only1")), TRUE);*/
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(ui_widgets.toolbar_menu, "images_only2")), TRUE);
break;
}
case GTK_TOOLBAR_TEXT:
{
/*gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "text_only1")), TRUE);*/
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(ui_widgets.toolbar_menu, "text_only2")), TRUE);
break;
}
}
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), toolbar_prefs.icon_style);
/* sets the icon size of the toolbar, use user preferences (.gtkrc) if not set */
if (toolbar_prefs.icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR ||
toolbar_prefs.icon_size == GTK_ICON_SIZE_LARGE_TOOLBAR ||
toolbar_prefs.icon_size == GTK_ICON_SIZE_MENU)
{
gtk_toolbar_set_icon_size(GTK_TOOLBAR(main_widgets.toolbar), toolbar_prefs.icon_size);
}
toolbar_apply_settings();
toolbar_update_ui();
ui_update_view_editor_menu_items();
......@@ -275,11 +245,6 @@ static void main_init(void)
main_status.opening_session_files = FALSE;
main_widgets.window = create_window1();
/* add recent files to the File menu */
ui_widgets.recent_files_menuitem = ui_lookup_widget(main_widgets.window, "recent_files1");
ui_widgets.recent_files_menu_menubar = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(ui_widgets.recent_files_menuitem),
ui_widgets.recent_files_menu_menubar);
/* add recent projects to the Project menu */
ui_widgets.recent_projects_menuitem = ui_lookup_widget(main_widgets.window, "recent_projects1");
......@@ -1018,22 +983,12 @@ gint main(gint argc, gchar **argv)
}
/* registering some basic events */
{
GtkWidget *entry;
g_signal_connect(main_widgets.window, "delete-event", G_CALLBACK(on_exit_clicked), NULL);
g_signal_connect(main_widgets.window, "window-state-event", G_CALLBACK(on_window_state_event), NULL);
g_signal_connect(main_widgets.toolbar, "button-press-event", G_CALLBACK(toolbar_popup_menu), NULL);
g_signal_connect(ui_lookup_widget(main_widgets.window, "textview_scribble"),
"motion-notify-event", G_CALLBACK(on_motion_event), NULL);
entry = toolbar_get_widget_child_by_name("SearchEntry");
if (entry != NULL)
g_signal_connect(entry, "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
entry = toolbar_get_widget_child_by_name("GotoEntry");
if (entry != NULL)
g_signal_connect(entry, "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
}
#ifdef HAVE_VTE
vte_init();
#endif
......
......@@ -1325,12 +1325,16 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
autosep->widget = GTK_WIDGET(sep);
gtk_toolbar_insert(toolbar, item, pos + 1);
toolbar_item_ref(sep);
toolbar_item_ref(item);
}
else
{
pos = gtk_toolbar_get_item_index(toolbar, GTK_TOOL_ITEM(autosep->widget));
g_return_if_fail(pos >= 0);
gtk_toolbar_insert(toolbar, item, pos);
toolbar_item_ref(item);
}
/* hide the separator widget if there are no toolbar items showing for the plugin */
ui_auto_separator_add_ref(autosep, GTK_WIDGET(item));
......
......@@ -37,6 +37,8 @@
#include "document.h"
#include "filetypes.h"
#include "ui_utils.h"
#include "toolbar.h"
#include "geanymenubuttonaction.h"
GeanyTemplatePrefs template_prefs;
......@@ -360,7 +362,7 @@ on_new_with_template (GtkMenuItem *menuitem,
/* template items for the new file menu */
static void create_new_menu_items(void)
static void create_new_menu_items(GtkWidget *toolbar_new_file_menu)
{
GSList *node;
......@@ -378,14 +380,11 @@ static void create_new_menu_items(void)
gtk_container_add(GTK_CONTAINER(new_with_template_menu), tmp_menu);
g_signal_connect(tmp_menu, "activate", G_CALLBACK(on_new_with_template), ft);
if (ui_widgets.new_file_menu != NULL)
{
tmp_button = gtk_menu_item_new_with_label(label);
gtk_widget_show(tmp_button);
gtk_container_add(GTK_CONTAINER(ui_widgets.new_file_menu), tmp_button);
gtk_container_add(GTK_CONTAINER(toolbar_new_file_menu), tmp_button);
g_signal_connect(tmp_button, "activate", G_CALLBACK(on_new_with_template), ft);
}
}
}
......@@ -443,6 +442,7 @@ on_new_with_file_template(GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer user_dat
static void add_file_item(gpointer data, gpointer user_data)
{
GtkWidget *tmp_menu, *tmp_button;
GtkWidget *toolbar_new_file_menu = user_data;
gchar *label;
g_return_if_fail(data);
......@@ -454,13 +454,11 @@ static void add_file_item(gpointer data, gpointer user_data)
gtk_container_add(GTK_CONTAINER(new_with_template_menu), tmp_menu);
g_signal_connect(tmp_menu, "activate", G_CALLBACK(on_new_with_file_template), NULL);
if (ui_widgets.new_file_menu != NULL)
{
tmp_button = gtk_menu_item_new_with_label(label);
gtk_widget_show(tmp_button);
gtk_container_add(GTK_CONTAINER(ui_widgets.new_file_menu), tmp_button);
gtk_container_add(GTK_CONTAINER(toolbar_new_file_menu), tmp_button);
g_signal_connect(tmp_button, "activate", G_CALLBACK(on_new_with_file_template), NULL);
}
g_free(label);
}
......@@ -485,7 +483,7 @@ static gint compare_filenames_by_filetype(gconstpointer a, gconstpointer b)
}
static gboolean add_custom_template_items(void)
static gboolean add_custom_template_items(GtkWidget *toolbar_new_file_menu)
{
gchar *path = g_build_path(G_DIR_SEPARATOR_S, app->configdir, GEANY_TEMPLATES_SUBDIR,
"files", NULL);
......@@ -497,7 +495,7 @@ static gboolean add_custom_template_items(void)
return FALSE;
}
list = g_slist_sort(list, compare_filenames_by_filetype);
g_slist_foreach(list, add_file_item, NULL);
g_slist_foreach(list, add_file_item, toolbar_new_file_menu);
g_slist_foreach(list, (GFunc) g_free, NULL);
g_slist_free(list);
g_free(path);
......@@ -508,23 +506,28 @@ static gboolean add_custom_template_items(void)
static void create_file_template_menus(void)
{
GtkWidget *sep1, *sep2 = NULL;
GtkWidget *toolbar_new_file_menu = NULL;
new_with_template_menu = ui_lookup_widget(main_widgets.window, "menu_new_with_template1_menu");
create_new_menu_items();
toolbar_new_file_menu = gtk_menu_new();
/* we hold our own ref on the menu in case it is not used in the toolbar */
g_object_ref(toolbar_new_file_menu);
create_new_menu_items(toolbar_new_file_menu);
sep1 = gtk_separator_menu_item_new();
gtk_container_add(GTK_CONTAINER(new_with_template_menu), sep1);
if (ui_widgets.new_file_menu != NULL)
{
sep2 = gtk_separator_menu_item_new();
gtk_container_add(GTK_CONTAINER(ui_widgets.new_file_menu), sep2);
}
if (add_custom_template_items())
gtk_container_add(GTK_CONTAINER(toolbar_new_file_menu), sep2);
if (add_custom_template_items(toolbar_new_file_menu))
{
gtk_widget_show(sep1);
if (sep2 != NULL)
gtk_widget_show(sep2);
}
geany_menu_button_action_set_menu(GEANY_MENU_BUTTON_ACTION(
toolbar_get_action_by_name("New")), toolbar_new_file_menu);
}
......@@ -806,6 +809,8 @@ void templates_free_templates(void)
{
gint i;
GList *children, *item;
GtkWidget *toolbar_new_file_menu = geany_menu_button_action_get_menu(
GEANY_MENU_BUTTON_ACTION(toolbar_get_action_by_name("New")));
for (i = 0; i < GEANY_MAX_TEMPLATES; i++)
{
......@@ -816,16 +821,14 @@ void templates_free_templates(void)
g_free(ft_templates[i]);
}
/* destroy "New with template" sub menu items (in case we want to reload the templates) */
if (ui_widgets.new_file_menu != NULL)
{
children = gtk_container_get_children(GTK_CONTAINER(ui_widgets.new_file_menu));
for (item = children; item != NULL; item = g_list_next(item))
children = gtk_container_get_children(GTK_CONTAINER(toolbar_new_file_menu));
foreach_list(item, children)
{
gtk_widget_destroy(GTK_WIDGET(item->data));
}
}
g_object_unref(toolbar_new_file_menu);
children = gtk_container_get_children(GTK_CONTAINER(new_with_template_menu));
for (item = children; item != NULL; item = g_list_next(item))
foreach_list(item, children)
{
gtk_widget_destroy(GTK_WIDGET(item->data));
}
......
This diff is collapsed.
......@@ -49,6 +49,10 @@ void toolbar_add_config_file_menu_item(void);
void toolbar_update_ui(void);
void toolbar_apply_settings(void);
void toolbar_item_ref(GtkToolItem *item);
GtkWidget *toolbar_init(void);
void toolbar_finalize(void);
......
......@@ -48,6 +48,7 @@
#include "plugins.h"
#include "symbols.h"
#include "toolbar.h"
#include "geanymenubuttonaction.h"
GeanyInterfacePrefs interface_prefs;
......@@ -58,7 +59,8 @@ UIWidgets ui_widgets;
static struct
{
/* pointers to widgets only sensitive when there is at least one document */
/* pointers to widgets only sensitive when there is at least one document, the pointers can
* also be GtkAction objects, so check each pointer before using it */
GPtrArray *document_buttons;
GtkWidget *menu_insert_include_items[2];
GtkWidget *popup_goto_items[4];
......@@ -610,7 +612,7 @@ void ui_save_buttons_toggle(gboolean enable)
g_ptr_array_add(widgets.document_buttons, ui_lookup_widget(main_widgets.window, widget_name))
#define add_doc_toolitem(widget_name) \
g_ptr_array_add(widgets.document_buttons, toolbar_get_widget_by_name(widget_name))
g_ptr_array_add(widgets.document_buttons, toolbar_get_action_by_name(widget_name))
static void init_document_widgets(void)
{
......@@ -686,6 +688,9 @@ void ui_document_buttons_update(void)
for (i = 0; i < widgets.document_buttons->len; i++)
{
GtkWidget *widget = g_ptr_array_index(widgets.document_buttons, i);
if (GTK_IS_ACTION(widget))
gtk_action_set_sensitive(GTK_ACTION(widget), enable);
else
ui_widget_set_sensitive(widget, enable);
}
}
......@@ -956,7 +961,8 @@ static GeanyRecentFiles *recent_get_recent_files(void)
{
grf.recent_queue = ui_prefs.recent_queue;
grf.menubar = ui_widgets.recent_files_menu_menubar;
grf.toolbar = ui_widgets.recent_files_menu_toolbar;
grf.toolbar = geany_menu_button_action_get_menu(GEANY_MENU_BUTTON_ACTION(
toolbar_get_action_by_name("Open")));
grf.activate_cb = recent_file_activate_cb;
}
return &grf;
......@@ -1798,10 +1804,39 @@ static void add_stock_items(void)
}
void ui_init_toolbar_widgets(void)
{
widgets.save_buttons[1] = toolbar_get_widget_by_name("Save");
widgets.save_buttons[3] = toolbar_get_widget_by_name("SaveAll");
widgets.redo_items[2] = toolbar_get_widget_by_name("Redo");
widgets.undo_items[2] = toolbar_get_widget_by_name("Undo");
}
static void init_recent_files(void)
{
GtkWidget *toolbar_recent_files_menu;
/* add recent files to the File menu */
ui_widgets.recent_files_menuitem = ui_lookup_widget(main_widgets.window, "recent_files1");
ui_widgets.recent_files_menu_menubar = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(ui_widgets.recent_files_menuitem),
ui_widgets.recent_files_menu_menubar);
/* add recent files to the toolbar Open button */
toolbar_recent_files_menu = gtk_menu_new();
g_object_ref(toolbar_recent_files_menu);
geany_menu_button_action_set_menu(GEANY_MENU_BUTTON_ACTION(
toolbar_get_action_by_name("Open")), toolbar_recent_files_menu);
}
void ui_init(void)
{
add_stock_items();
init_recent_files();
ui_widgets.statusbar = ui_lookup_widget(main_widgets.window, "statusbar");
ui_widgets.print_page_setup = ui_lookup_widget(main_widgets.window, "page_setup1");
......@@ -1820,16 +1855,13 @@ void ui_init(void)
widgets.menu_insert_include_items[0] = ui_lookup_widget(main_widgets.editor_menu, "insert_include1");
widgets.menu_insert_include_items[1] = ui_lookup_widget(main_widgets.window, "insert_include2");
widgets.save_buttons[0] = ui_lookup_widget(main_widgets.window, "menu_save1");
widgets.save_buttons[1] = toolbar_get_widget_by_name("Save");
widgets.save_buttons[2] = ui_lookup_widget(main_widgets.window, "menu_save_all1");
widgets.save_buttons[3] = toolbar_get_widget_by_name("SaveAll");
widgets.redo_items[0] = ui_lookup_widget(main_widgets.editor_menu, "redo1");
widgets.redo_items[1] = ui_lookup_widget(main_widgets.window, "menu_redo2");
widgets.redo_items[2] = toolbar_get_widget_by_name("Redo");
widgets.undo_items[0] = ui_lookup_widget(main_widgets.editor_menu, "undo1");
widgets.undo_items[1] = ui_lookup_widget(main_widgets.window, "menu_undo2");
widgets.undo_items[2] = toolbar_get_widget_by_name("Undo");
ui_init_toolbar_widgets();
init_document_widgets();
create_config_files_menu();
toolbar_add_config_file_menu_item();
......@@ -1853,7 +1885,6 @@ static void on_auto_separator_item_show_hide(GtkWidget *widget, gpointer user_da
autosep->ref_count++;
else
autosep->ref_count--;
auto_separator_update(autosep);
}
......
......@@ -103,10 +103,8 @@ typedef struct UIWidgets
{
/* menu widgets */
GtkWidget *toolbar_menu;
GtkWidget *new_file_menu;
GtkWidget *recent_files_menuitem;
GtkWidget *recent_files_menu_menubar;
GtkWidget *recent_files_menu_toolbar;
GtkWidget *print_page_setup;
GtkWidget *recent_projects_menuitem;
GtkWidget *recent_projects_menu_menubar;
......@@ -205,6 +203,8 @@ void ui_entry_add_clear_icon(GtkWidget *entry);
void ui_init(void);
void ui_init_toolbar_widgets(void);
void ui_add_config_file_menu_item(const gchar *real_path, const gchar *label,
GtkContainer *parent);
......
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