|
Lines 36-41
Link Here
|
| 36 |
#include <libgnomevfs/gnome-vfs.h> |
36 |
#include <libgnomevfs/gnome-vfs.h> |
| 37 |
#include <libgnomevfs/gnome-vfs-mime-handlers.h> |
37 |
#include <libgnomevfs/gnome-vfs-mime-handlers.h> |
| 38 |
|
38 |
|
|
|
39 |
#include <gtk/gtkversion.h> |
| 40 |
#if GTK_CHECK_VERSION (2, 10, 0) |
| 41 |
# define USE_GTK_RECENT_MANAGER |
| 42 |
#endif |
| 43 |
|
| 39 |
#include "tile.h" |
44 |
#include "tile.h" |
| 40 |
#include "application-tile.h" |
45 |
#include "application-tile.h" |
| 41 |
#include "document-tile.h" |
46 |
#include "document-tile.h" |
|
Lines 119-124
typedef struct {
Link Here
|
| 119 |
GnomeVFSVolumeMonitor *volume_mon; |
124 |
GnomeVFSVolumeMonitor *volume_mon; |
| 120 |
GList *mounts; |
125 |
GList *mounts; |
| 121 |
|
126 |
|
|
|
127 |
guint recently_used_throttle_timeout_id; |
| 128 |
GnomeVFSMonitorHandle *recently_used_store_monitor; |
| 129 |
|
| 122 |
guint search_cmd_gconf_mntr_id; |
130 |
guint search_cmd_gconf_mntr_id; |
| 123 |
guint current_page_gconf_mntr_id; |
131 |
guint current_page_gconf_mntr_id; |
| 124 |
guint more_link_vis_gconf_mntr_id; |
132 |
guint more_link_vis_gconf_mntr_id; |
|
Lines 136-141
typedef struct {
Link Here
|
| 136 |
|
144 |
|
| 137 |
gboolean ptr_is_grabbed; |
145 |
gboolean ptr_is_grabbed; |
| 138 |
gboolean kbd_is_grabbed; |
146 |
gboolean kbd_is_grabbed; |
|
|
147 |
|
| 148 |
guint recently_used_store_has_changed : 1; |
| 139 |
} MainMenuUIPrivate; |
149 |
} MainMenuUIPrivate; |
| 140 |
|
150 |
|
| 141 |
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MAIN_MENU_UI_TYPE, MainMenuUIPrivate)) |
151 |
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MAIN_MENU_UI_TYPE, MainMenuUIPrivate)) |
|
Lines 157-162
static void create_more_buttons (MainMenuUI *);
Link Here
|
| 157 |
static void setup_file_tables (MainMenuUI *); |
167 |
static void setup_file_tables (MainMenuUI *); |
| 158 |
static void setup_bookmark_agents (MainMenuUI *); |
168 |
static void setup_bookmark_agents (MainMenuUI *); |
| 159 |
static void setup_lock_down (MainMenuUI *); |
169 |
static void setup_lock_down (MainMenuUI *); |
|
|
170 |
static void setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup); |
| 171 |
static void update_recently_used_sections (MainMenuUI *this); |
| 160 |
|
172 |
|
| 161 |
static void select_page (MainMenuUI *); |
173 |
static void select_page (MainMenuUI *); |
| 162 |
static void update_limits (MainMenuUI *); |
174 |
static void update_limits (MainMenuUI *); |
|
Lines 277-301
main_menu_ui_new (PanelApplet *applet)
Link Here
|
| 277 |
priv->panel_button_xml = glade_xml_new (glade_xml_path, "slab-panel-button-root", NULL); |
289 |
priv->panel_button_xml = glade_xml_new (glade_xml_path, "slab-panel-button-root", NULL); |
| 278 |
g_free (glade_xml_path); |
290 |
g_free (glade_xml_path); |
| 279 |
|
291 |
|
|
|
292 |
libslab_checkpoint ("main_menu_ui_new(): setup_recently_used_store_monitor"); |
| 293 |
setup_recently_used_store_monitor (this, TRUE); |
| 294 |
libslab_checkpoint ("main_menu_ui_new(): setup_bookmark_agents"); |
| 280 |
setup_bookmark_agents (this); |
295 |
setup_bookmark_agents (this); |
|
|
296 |
libslab_checkpoint ("main_menu_ui_new(): create_panel_button"); |
| 281 |
create_panel_button (this); |
297 |
create_panel_button (this); |
|
|
298 |
libslab_checkpoint ("main_menu_ui_new(): create_slab_window"); |
| 282 |
create_slab_window (this); |
299 |
create_slab_window (this); |
|
|
300 |
libslab_checkpoint ("main_menu_ui_new(): create_search_section"); |
| 283 |
create_search_section (this); |
301 |
create_search_section (this); |
|
|
302 |
libslab_checkpoint ("main_menu_ui_new(): create_file_section"); |
| 284 |
create_file_section (this); |
303 |
create_file_section (this); |
|
|
304 |
libslab_checkpoint ("main_menu_ui_new(): create_user_apps_section"); |
| 285 |
create_user_apps_section (this); |
305 |
create_user_apps_section (this); |
|
|
306 |
libslab_checkpoint ("main_menu_ui_new(): create_rct_apps_section"); |
| 286 |
create_rct_apps_section (this); |
307 |
create_rct_apps_section (this); |
|
|
308 |
libslab_checkpoint ("main_menu_ui_new(): create_user_docs_section"); |
| 287 |
create_user_docs_section (this); |
309 |
create_user_docs_section (this); |
|
|
310 |
libslab_checkpoint ("main_menu_ui_new(): create_rct_docs_section"); |
| 288 |
create_rct_docs_section (this); |
311 |
create_rct_docs_section (this); |
|
|
312 |
libslab_checkpoint ("main_menu_ui_new(): create_user_dirs_section"); |
| 289 |
create_user_dirs_section (this); |
313 |
create_user_dirs_section (this); |
|
|
314 |
libslab_checkpoint ("main_menu_ui_new(): create_system_section"); |
| 290 |
create_system_section (this); |
315 |
create_system_section (this); |
|
|
316 |
libslab_checkpoint ("main_menu_ui_new(): create_status_section"); |
| 291 |
create_status_section (this); |
317 |
create_status_section (this); |
|
|
318 |
libslab_checkpoint ("main_menu_ui_new(): create_more_buttons"); |
| 292 |
create_more_buttons (this); |
319 |
create_more_buttons (this); |
|
|
320 |
libslab_checkpoint ("main_menu_ui_new(): setup_file_tables"); |
| 293 |
setup_file_tables (this); |
321 |
setup_file_tables (this); |
|
|
322 |
libslab_checkpoint ("main_menu_ui_new(): setup_lock_down"); |
| 294 |
setup_lock_down (this); |
323 |
setup_lock_down (this); |
| 295 |
|
324 |
|
|
|
325 |
libslab_checkpoint ("main_menu_ui_new(): bind_beagle_search_key"); |
| 296 |
bind_beagle_search_key (this); |
326 |
bind_beagle_search_key (this); |
| 297 |
update_limits (this); |
327 |
libslab_checkpoint ("main_menu_ui_new(): select_page"); |
| 298 |
select_page (this); |
328 |
select_page (this); |
|
|
329 |
libslab_checkpoint ("main_menu_ui_new(): apply_lockdown_settings"); |
| 299 |
apply_lockdown_settings (this); |
330 |
apply_lockdown_settings (this); |
| 300 |
|
331 |
|
| 301 |
return this; |
332 |
return this; |
|
Lines 404-409
main_menu_ui_finalize (GObject *g_obj)
Link Here
|
| 404 |
|
435 |
|
| 405 |
gint i; |
436 |
gint i; |
| 406 |
|
437 |
|
|
|
438 |
if (priv->recently_used_store_monitor) |
| 439 |
gnome_vfs_monitor_cancel (priv->recently_used_store_monitor); |
| 440 |
|
| 441 |
if (priv->recently_used_throttle_timeout_id) |
| 442 |
g_source_remove (priv->recently_used_throttle_timeout_id); |
| 407 |
|
443 |
|
| 408 |
for (i = 0; i < 4; ++i) { |
444 |
for (i = 0; i < 4; ++i) { |
| 409 |
g_object_unref (G_OBJECT (g_object_get_data ( |
445 |
g_object_unref (G_OBJECT (g_object_get_data ( |
|
Lines 921-926
setup_lock_down (MainMenuUI *this)
Link Here
|
| 921 |
DISABLE_LOCKSCREEN_GCONF_KEY, lockdown_notify_cb, this); |
957 |
DISABLE_LOCKSCREEN_GCONF_KEY, lockdown_notify_cb, this); |
| 922 |
} |
958 |
} |
| 923 |
|
959 |
|
|
|
960 |
static char * |
| 961 |
get_recently_used_store_filename (void) |
| 962 |
{ |
| 963 |
const char *basename; |
| 964 |
|
| 965 |
#ifdef USE_GTK_RECENT_MANAGER |
| 966 |
basename = ".recently-used.xbel"; |
| 967 |
#else |
| 968 |
basename = ".recently-used"; |
| 969 |
#endif |
| 970 |
|
| 971 |
return g_build_filename (g_get_home_dir (), basename, NULL); |
| 972 |
} |
| 973 |
|
| 974 |
static gboolean |
| 975 |
recently_used_throttle_timeout_cb (gpointer data) |
| 976 |
{ |
| 977 |
MainMenuUI *this = MAIN_MENU_UI (data); |
| 978 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 979 |
|
| 980 |
update_recently_used_sections (this); |
| 981 |
|
| 982 |
priv->recently_used_throttle_timeout_id = 0; |
| 983 |
|
| 984 |
return FALSE; |
| 985 |
} |
| 986 |
|
| 987 |
#define RECENTLY_USED_STORE_THROTTLE_SECONDS 2 |
| 988 |
|
| 989 |
static void |
| 990 |
setup_recently_used_throttle_timeout (MainMenuUI *this, gboolean is_startup) |
| 991 |
{ |
| 992 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 993 |
|
| 994 |
if (priv->recently_used_throttle_timeout_id != 0) |
| 995 |
g_source_remove (priv->recently_used_throttle_timeout_id); |
| 996 |
|
| 997 |
/* Some apps do many updates to the recently-used store quickly, like |
| 998 |
* when Nautilus or EOG are asked to open a bunch of files at the same |
| 999 |
* time. So, we throttle our updates to the recently-used store to |
| 1000 |
* avoid re-reading the store more times than needed. |
| 1001 |
* |
| 1002 |
* Additionally, we do this in an idle during startup, not a timeout, |
| 1003 |
* so that the Computer menu will be up to date as soon as possible. |
| 1004 |
*/ |
| 1005 |
if (is_startup) |
| 1006 |
priv->recently_used_throttle_timeout_id = g_idle_add (recently_used_throttle_timeout_cb, this); |
| 1007 |
else |
| 1008 |
priv->recently_used_throttle_timeout_id = g_timeout_add_seconds (RECENTLY_USED_STORE_THROTTLE_SECONDS, |
| 1009 |
recently_used_throttle_timeout_cb, |
| 1010 |
this); |
| 1011 |
} |
| 1012 |
|
| 1013 |
/* Called from GnomeVFSMonitor when the recently-used store changes. We'll note |
| 1014 |
* this in a flag, and we'll check that flag later, when it is necessary to have |
| 1015 |
* an up-to-date view of the recently-used store. |
| 1016 |
*/ |
| 1017 |
static void recently_used_store_monitor_changed_cb (GnomeVFSMonitorHandle *handle, |
| 1018 |
const gchar *monitor_uri, |
| 1019 |
const gchar *info_uri, |
| 1020 |
GnomeVFSMonitorEventType event_type, |
| 1021 |
gpointer data) |
| 1022 |
{ |
| 1023 |
MainMenuUI *this = MAIN_MENU_UI (data); |
| 1024 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 1025 |
|
| 1026 |
priv->recently_used_store_has_changed = TRUE; |
| 1027 |
setup_recently_used_throttle_timeout (this, FALSE); |
| 1028 |
} |
| 1029 |
|
| 1030 |
/* Creates a GnomeVFSMonitor for the recently-used store, so we can be informed |
| 1031 |
* when the store changes. |
| 1032 |
*/ |
| 1033 |
static void |
| 1034 |
setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup) |
| 1035 |
{ |
| 1036 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 1037 |
char *filename; |
| 1038 |
char *uri; |
| 1039 |
|
| 1040 |
priv->recently_used_store_has_changed = TRUE; /* ensure the store gets read the first time we need it */ |
| 1041 |
|
| 1042 |
filename = get_recently_used_store_filename (); |
| 1043 |
uri = g_strconcat ("file://", filename, NULL); |
| 1044 |
g_free (filename); |
| 1045 |
|
| 1046 |
if (gnome_vfs_monitor_add (&priv->recently_used_store_monitor, |
| 1047 |
uri, |
| 1048 |
GNOME_VFS_MONITOR_FILE, |
| 1049 |
recently_used_store_monitor_changed_cb, |
| 1050 |
this) != GNOME_VFS_OK) |
| 1051 |
priv->recently_used_store_monitor = NULL; |
| 1052 |
|
| 1053 |
g_free (uri); |
| 1054 |
|
| 1055 |
setup_recently_used_throttle_timeout (this, is_startup); |
| 1056 |
} |
| 1057 |
|
| 924 |
static Tile * |
1058 |
static Tile * |
| 925 |
item_to_user_app_tile (BookmarkItem *item, gpointer data) |
1059 |
item_to_user_app_tile (BookmarkItem *item, gpointer data) |
| 926 |
{ |
1060 |
{ |
|
Lines 1492-1497
apply_lockdown_settings (MainMenuUI *this)
Link Here
|
| 1492 |
GList *node; |
1626 |
GList *node; |
| 1493 |
gint i; |
1627 |
gint i; |
| 1494 |
|
1628 |
|
|
|
1629 |
libslab_checkpoint ("apply_lockdown_settings(): start"); |
| 1495 |
|
1630 |
|
| 1496 |
more_link_visible = GPOINTER_TO_INT (libslab_get_gconf_value (MORE_LINK_VIS_GCONF_KEY)); |
1631 |
more_link_visible = GPOINTER_TO_INT (libslab_get_gconf_value (MORE_LINK_VIS_GCONF_KEY)); |
| 1497 |
status_area_visible = GPOINTER_TO_INT (libslab_get_gconf_value (STATUS_VIS_GCONF_KEY)); |
1632 |
status_area_visible = GPOINTER_TO_INT (libslab_get_gconf_value (STATUS_VIS_GCONF_KEY)); |
|
Lines 1531-1543
apply_lockdown_settings (MainMenuUI *this)
Link Here
|
| 1531 |
for (i = 0; i < 5; ++i) |
1666 |
for (i = 0; i < 5; ++i) |
| 1532 |
set_table_section_visible (this, priv->file_tables [i]); |
1667 |
set_table_section_visible (this, priv->file_tables [i]); |
| 1533 |
|
1668 |
|
|
|
1669 |
libslab_checkpoint ("apply_lockdown_settings(): loading sys_table"); |
| 1534 |
tile_table_reload (priv->sys_table); |
1670 |
tile_table_reload (priv->sys_table); |
|
|
1671 |
|
| 1672 |
libslab_checkpoint ("apply_lockdown_settings(): loading user_apps_table"); |
| 1535 |
tile_table_reload (priv->file_tables [USER_APPS_TABLE]); |
1673 |
tile_table_reload (priv->file_tables [USER_APPS_TABLE]); |
| 1536 |
tile_table_reload (priv->file_tables [RCNT_APPS_TABLE]); |
1674 |
|
|
|
1675 |
libslab_checkpoint ("apply_lockdown_settings(): loading user_docs_table"); |
| 1537 |
tile_table_reload (priv->file_tables [USER_DOCS_TABLE]); |
1676 |
tile_table_reload (priv->file_tables [USER_DOCS_TABLE]); |
|
|
1677 |
|
| 1678 |
libslab_checkpoint ("apply_lockdown_settings(): loading user_dirs_table"); |
| 1538 |
tile_table_reload (priv->file_tables [USER_DIRS_TABLE]); |
1679 |
tile_table_reload (priv->file_tables [USER_DIRS_TABLE]); |
| 1539 |
|
1680 |
|
|
|
1681 |
libslab_checkpoint ("apply_lockdown_settings(): update_limits"); |
| 1540 |
update_limits (this); |
1682 |
update_limits (this); |
|
|
1683 |
|
| 1684 |
libslab_checkpoint ("apply_lockdown_settings(): end"); |
| 1541 |
} |
1685 |
} |
| 1542 |
|
1686 |
|
| 1543 |
static void |
1687 |
static void |
|
Lines 1616-1621
exit:
Link Here
|
| 1616 |
xmlFreeDoc (doc); |
1760 |
xmlFreeDoc (doc); |
| 1617 |
} |
1761 |
} |
| 1618 |
|
1762 |
|
|
|
1763 |
static GBookmarkFile * |
| 1764 |
load_recently_used_store (void) |
| 1765 |
{ |
| 1766 |
GBookmarkFile *store; |
| 1767 |
char *filename; |
| 1768 |
|
| 1769 |
store = g_bookmark_file_new (); |
| 1770 |
|
| 1771 |
filename = get_recently_used_store_filename (); |
| 1772 |
|
| 1773 |
/* FIXME: if we can't load the store, do we need to hide the |
| 1774 |
* recently-used sections in the GUI? If so, do that in the caller(s) |
| 1775 |
* of this function, not here. |
| 1776 |
*/ |
| 1777 |
|
| 1778 |
libslab_checkpoint ("main-menu-ui.c: load_recently_used_store(): start loading %s", filename); |
| 1779 |
g_bookmark_file_load_from_file (store, filename, NULL); /* NULL-GError */ |
| 1780 |
libslab_checkpoint ("main-menu-ui.c: load_recently_used_store(): end loading %s", filename); |
| 1781 |
|
| 1782 |
g_free (filename); |
| 1783 |
|
| 1784 |
return store; |
| 1785 |
} |
| 1786 |
|
| 1787 |
/* Updates the bookmark agents for the recently-used apps and documents, by reading the |
| 1788 |
* recently-used store. |
| 1789 |
*/ |
| 1790 |
static void |
| 1791 |
update_recently_used_bookmark_agents (MainMenuUI *this) |
| 1792 |
{ |
| 1793 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 1794 |
GBookmarkFile *store; |
| 1795 |
|
| 1796 |
store = load_recently_used_store (); |
| 1797 |
|
| 1798 |
bookmark_agent_update_from_bookmark_file (priv->bm_agents[BOOKMARK_STORE_RECENT_APPS], store); |
| 1799 |
bookmark_agent_update_from_bookmark_file (priv->bm_agents[BOOKMARK_STORE_RECENT_DOCS], store); |
| 1800 |
|
| 1801 |
g_bookmark_file_free (store); |
| 1802 |
} |
| 1803 |
|
| 1804 |
/* Updates the recently-used tile tables from their corresponding bookmark agents */ |
| 1805 |
static void |
| 1806 |
update_recently_used_tables (MainMenuUI *this) |
| 1807 |
{ |
| 1808 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 1809 |
|
| 1810 |
tile_table_reload (priv->file_tables[RCNT_APPS_TABLE]); |
| 1811 |
tile_table_reload (priv->file_tables[RCNT_DOCS_TABLE]); |
| 1812 |
} |
| 1813 |
|
| 1814 |
/* If the recently-used store has changed since the last time we updated from |
| 1815 |
* it, this updates our view of the store and the corresponding sections in the |
| 1816 |
* slab_window. |
| 1817 |
*/ |
| 1818 |
static void |
| 1819 |
update_recently_used_sections (MainMenuUI *this) |
| 1820 |
{ |
| 1821 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 1822 |
|
| 1823 |
libslab_checkpoint ("main-menu-ui.c: update_recently_used_sections() start"); |
| 1824 |
|
| 1825 |
if (priv->recently_used_store_has_changed) { |
| 1826 |
update_recently_used_bookmark_agents (this); |
| 1827 |
update_recently_used_tables (this); |
| 1828 |
|
| 1829 |
priv->recently_used_store_has_changed = FALSE; |
| 1830 |
} |
| 1831 |
|
| 1832 |
if (!priv->recently_used_store_monitor) |
| 1833 |
setup_recently_used_store_monitor (this, FALSE); /* for if we couldn't create the monitor the first time */ |
| 1834 |
|
| 1835 |
libslab_checkpoint ("main-menu-ui.c: update_recently_used_sections() end"); |
| 1836 |
} |
| 1837 |
|
| 1838 |
/* Updates the slab_window's sections that need updating and presents the window */ |
| 1839 |
static void |
| 1840 |
present_slab_window (MainMenuUI *this) |
| 1841 |
{ |
| 1842 |
MainMenuUIPrivate *priv = PRIVATE (this); |
| 1843 |
|
| 1844 |
update_recently_used_sections (this); |
| 1845 |
|
| 1846 |
gtk_window_present_with_time (GTK_WINDOW (priv->slab_window), gtk_get_current_event_time ()); |
| 1847 |
} |
| 1848 |
|
| 1619 |
static void |
1849 |
static void |
| 1620 |
panel_button_clicked_cb (GtkButton *button, gpointer user_data) |
1850 |
panel_button_clicked_cb (GtkButton *button, gpointer user_data) |
| 1621 |
{ |
1851 |
{ |
|
Lines 1636-1642
panel_button_clicked_cb (GtkButton *button, gpointer user_data)
Link Here
|
| 1636 |
|
1866 |
|
| 1637 |
if (! double_click_detector_is_double_click (detector, gtk_get_current_event_time (), TRUE)) { |
1867 |
if (! double_click_detector_is_double_click (detector, gtk_get_current_event_time (), TRUE)) { |
| 1638 |
if (! visible) |
1868 |
if (! visible) |
| 1639 |
gtk_window_present_with_time (GTK_WINDOW (priv->slab_window), gtk_get_current_event_time ()); |
1869 |
present_slab_window (this); |
| 1640 |
else |
1870 |
else |
| 1641 |
gtk_widget_hide (priv->slab_window); |
1871 |
gtk_widget_hide (priv->slab_window); |
| 1642 |
|
1872 |
|