Mercurial > geeqie.yaz
comparison src/layout_util.c @ 1463:25168240a247
added function to reload external editors at any time
eliminated init_after_global_options()
author | nadvornik |
---|---|
date | Fri, 20 Mar 2009 09:46:35 +0000 |
parents | e015b6573d36 |
children | 1b3751ac4743 |
comparison
equal
deleted
inserted
replaced
1462:75721f22155c | 1463:25168240a247 |
---|---|
1664 { | 1664 { |
1665 GError *error; | 1665 GError *error; |
1666 GList *editors_list; | 1666 GList *editors_list; |
1667 GList *work; | 1667 GList *work; |
1668 GList *old_path; | 1668 GList *old_path; |
1669 GString *desc = g_string_new( | 1669 GString *desc; |
1670 | |
1671 lw->action_group_editors = gtk_action_group_new("MenuActionsExternal"); | |
1672 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group_editors, 1); | |
1673 | |
1674 /* lw->action_group_editors contains translated entries, no translate func is required */ | |
1675 desc = g_string_new( | |
1670 "<ui>" | 1676 "<ui>" |
1671 " <menubar name='MainMenu'>"); | 1677 " <menubar name='MainMenu'>"); |
1672 | 1678 |
1673 editors_list = editor_list_get(); | 1679 editors_list = editor_list_get(); |
1674 | 1680 |
1682 | 1688 |
1683 if (editor->icon && register_theme_icon_as_stock(editor->key, editor->icon)) | 1689 if (editor->icon && register_theme_icon_as_stock(editor->key, editor->icon)) |
1684 { | 1690 { |
1685 entry.stock_id = editor->key; | 1691 entry.stock_id = editor->key; |
1686 } | 1692 } |
1687 gtk_action_group_add_actions(lw->action_group_external, &entry, 1, lw); | 1693 gtk_action_group_add_actions(lw->action_group_editors, &entry, 1, lw); |
1688 | 1694 |
1689 path = layout_actions_editor_menu_path(editor); | 1695 path = layout_actions_editor_menu_path(editor); |
1690 layout_actions_editor_add(desc, path, old_path); | 1696 layout_actions_editor_add(desc, path, old_path); |
1691 | 1697 |
1692 string_list_free(old_path); | 1698 string_list_free(old_path); |
1699 | 1705 |
1700 g_string_append(desc, " </menubar>" | 1706 g_string_append(desc, " </menubar>" |
1701 "</ui>" ); | 1707 "</ui>" ); |
1702 | 1708 |
1703 error = NULL; | 1709 error = NULL; |
1704 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1, &error)) | 1710 |
1711 lw->ui_editors_id = gtk_ui_manager_add_ui_from_string(lw->ui_manager, desc->str, -1, &error); | |
1712 if (!lw->ui_editors_id) | |
1705 { | 1713 { |
1706 g_message("building menus failed: %s", error->message); | 1714 g_message("building menus failed: %s", error->message); |
1707 g_error_free(error); | 1715 g_error_free(error); |
1708 exit(EXIT_FAILURE); | 1716 exit(EXIT_FAILURE); |
1709 } | 1717 } |
1717 | 1725 |
1718 if (lw->ui_manager) return; | 1726 if (lw->ui_manager) return; |
1719 | 1727 |
1720 lw->action_group = gtk_action_group_new("MenuActions"); | 1728 lw->action_group = gtk_action_group_new("MenuActions"); |
1721 gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL); | 1729 gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL); |
1722 lw->action_group_external = gtk_action_group_new("MenuActionsExternal"); | |
1723 /* lw->action_group_external contains translated entries, no translate func is required */ | |
1724 | 1730 |
1725 gtk_action_group_add_actions(lw->action_group, | 1731 gtk_action_group_add_actions(lw->action_group, |
1726 menu_entries, G_N_ELEMENTS(menu_entries), lw); | 1732 menu_entries, G_N_ELEMENTS(menu_entries), lw); |
1727 gtk_action_group_add_toggle_actions(lw->action_group, | 1733 gtk_action_group_add_toggle_actions(lw->action_group, |
1728 menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw); | 1734 menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw); |
1737 0, G_CALLBACK(layout_menu_view_dir_as_cb), lw); | 1743 0, G_CALLBACK(layout_menu_view_dir_as_cb), lw); |
1738 | 1744 |
1739 lw->ui_manager = gtk_ui_manager_new(); | 1745 lw->ui_manager = gtk_ui_manager_new(); |
1740 gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE); | 1746 gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE); |
1741 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0); | 1747 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0); |
1742 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group_external, 1); | |
1743 | 1748 |
1744 error = NULL; | 1749 error = NULL; |
1745 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error)) | 1750 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error)) |
1746 { | 1751 { |
1747 g_message("building menus failed: %s", error->message); | 1752 g_message("building menus failed: %s", error->message); |
1753 layout_toolbar_add_default(lw); | 1758 layout_toolbar_add_default(lw); |
1754 | 1759 |
1755 layout_actions_setup_marks(lw); | 1760 layout_actions_setup_marks(lw); |
1756 layout_actions_setup_editors(lw); | 1761 layout_actions_setup_editors(lw); |
1757 layout_copy_path_update(lw); | 1762 layout_copy_path_update(lw); |
1763 } | |
1764 | |
1765 void layout_editors_reload_all(void) | |
1766 { | |
1767 GList *work; | |
1768 | |
1769 work = layout_window_list; | |
1770 while (work) | |
1771 { | |
1772 LayoutWindow *lw = work->data; | |
1773 work = work->next; | |
1774 | |
1775 gtk_ui_manager_remove_ui(lw->ui_manager, lw->ui_editors_id); | |
1776 gtk_ui_manager_remove_action_group(lw->ui_manager, lw->action_group_editors); | |
1777 g_object_unref(lw->action_group_editors); | |
1778 } | |
1779 | |
1780 editor_load_descriptions(); | |
1781 | |
1782 work = layout_window_list; | |
1783 while (work) | |
1784 { | |
1785 LayoutWindow *lw = work->data; | |
1786 work = work->next; | |
1787 layout_actions_setup_editors(lw); | |
1788 } | |
1758 } | 1789 } |
1759 | 1790 |
1760 void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window) | 1791 void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window) |
1761 { | 1792 { |
1762 GtkAccelGroup *group; | 1793 GtkAccelGroup *group; |