main-menu-ui.c 65.2 KB
Newer Older
Jim Krehl's avatar
Jim Krehl committed
1 2 3
/*
 * This file is part of the Main Menu.
 *
4
 * Copyright (c) 2006, 2007 Novell, Inc.
Jim Krehl's avatar
Jim Krehl committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * The Main Menu is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * The Main Menu is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * the Main Menu; if not, write to the Free Software Foundation, Inc., 51
 * Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

21 22
#include "main-menu-ui.h"

Jim Krehl's avatar
Jim Krehl committed
23 24 25 26
#ifdef HAVE_CONFIG_H
#	include <config.h>
#endif

27 28 29 30
#include <panel-applet.h>
#include <glade/glade.h>
#include <cairo.h>
#include <string.h>
Jim Krehl's avatar
Jim Krehl committed
31 32
#include <libxml/parser.h>
#include <libxml/tree.h>
33
#include <gdk/gdkkeysyms.h>
Jim Krehl's avatar
Jim Krehl committed
34
#include <X11/Xlib.h>
35
#include <gdk/gdkx.h>
Jim Krehl's avatar
Jim Krehl committed
36 37
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
Jim Krehl's avatar
Jim Krehl committed
38

39
#include "tile.h"
Jim Krehl's avatar
Jim Krehl committed
40 41 42 43
#include "application-tile.h"
#include "document-tile.h"
#include "directory-tile.h"
#include "system-tile.h"
44 45
#include "hard-drive-status-tile.h"
#include "network-status-tile.h"
Jim Krehl's avatar
Jim Krehl committed
46

Jim Krehl's avatar
Jim Krehl committed
47
#include "tile-table.h"
Jim Krehl's avatar
Jim Krehl committed
48

49 50
#include "tomboykeybinder.h"
#include "libslab-utils.h"
Jim Krehl's avatar
Jim Krehl committed
51 52
#include "double-click-detector.h"

53 54 55 56 57 58 59 60 61
#define ROOT_GCONF_DIR             "/desktop/gnome/applications/main-menu"
#define CURRENT_PAGE_GCONF_KEY     ROOT_GCONF_DIR "/file-area/file_class"
#define URGENT_CLOSE_GCONF_KEY     ROOT_GCONF_DIR "/urgent_close"
#define MAX_TOTAL_ITEMS_GCONF_KEY  ROOT_GCONF_DIR "/file-area/max_total_items"
#define MIN_RECENT_ITEMS_GCONF_KEY ROOT_GCONF_DIR "/file-area/min_recent_items"
#define APP_BROWSER_GCONF_KEY      ROOT_GCONF_DIR "/application_browser"
#define FILE_BROWSER_GCONF_KEY     ROOT_GCONF_DIR "/file_browser"
#define SEARCH_CMD_GCONF_KEY       ROOT_GCONF_DIR "/search_command"
#define FILE_MGR_OPEN_GCONF_KEY    ROOT_GCONF_DIR "/file-area/file_mgr_open_cmd"
Jim Krehl's avatar
Jim Krehl committed
62
#define APP_BLACKLIST_GCONF_KEY    ROOT_GCONF_DIR "/file-area/file_blacklist"
63

64 65 66 67 68 69 70 71 72 73 74 75 76 77
#define LOCKDOWN_GCONF_DIR           ROOT_GCONF_DIR "/lock-down"
#define MORE_LINK_VIS_GCONF_KEY      LOCKDOWN_GCONF_DIR "/application_browser_link_visible"
#define SEARCH_VIS_GCONF_KEY         LOCKDOWN_GCONF_DIR "/search_area_visible"
#define STATUS_VIS_GCONF_KEY         LOCKDOWN_GCONF_DIR "/status_area_visible"
#define SYSTEM_VIS_GCONF_KEY         LOCKDOWN_GCONF_DIR "/system_area_visible"
#define SHOWABLE_TYPES_GCONF_KEY     LOCKDOWN_GCONF_DIR "/showable_file_types"
#define MODIFIABLE_SYSTEM_GCONF_KEY  LOCKDOWN_GCONF_DIR "/user_modifiable_system_area"
#define MODIFIABLE_APPS_GCONF_KEY    LOCKDOWN_GCONF_DIR "/user_modifiable_apps"
#define MODIFIABLE_DOCS_GCONF_KEY    LOCKDOWN_GCONF_DIR "/user_modifiable_docs"
#define MODIFIABLE_DIRS_GCONF_KEY    LOCKDOWN_GCONF_DIR "/user_modifiable_dirs"
#define DISABLE_TERMINAL_GCONF_KEY   "/desktop/gnome/lockdown/disable_command_line"
#define PANEL_LOCKDOWN_GCONF_DIR     "/apps/panel/global"
#define DISABLE_LOGOUT_GCONF_KEY     PANEL_LOCKDOWN_GCONF_DIR "/disable_log_out"
#define DISABLE_LOCKSCREEN_GCONF_KEY PANEL_LOCKDOWN_GCONF_DIR "/disable_lock_screen"
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

G_DEFINE_TYPE (MainMenuUI, main_menu_ui, G_TYPE_OBJECT)

typedef struct {
	PanelApplet *panel_applet;
	GtkWidget   *panel_about_dialog;

	GladeXML *main_menu_xml;
	GladeXML *panel_button_xml;

	GtkToggleButton *panel_buttons [4];
	GtkToggleButton *panel_button;

	GtkWidget *slab_window;

	GtkWidget *top_pane;
	GtkWidget *left_pane;

	GtkWidget *search_section;
	GtkWidget *search_entry;

	GtkNotebook *file_section;
	GtkWidget   *page_selectors    [3];
	gint         notebook_page_ids [3];

Jim Krehl's avatar
Jim Krehl committed
103 104 105
	TileTable     *file_tables     [5];
	GtkWidget     *table_sections  [5];
	gboolean       allowable_types [5];
Jim Krehl's avatar
Jim Krehl committed
106

107
	TileTable *sys_table;
Jim Krehl's avatar
Jim Krehl committed
108

109 110
	GtkWidget *more_buttons  [3];
	GtkWidget *more_sections [3];
Jim Krehl's avatar
Jim Krehl committed
111

112 113 114 115 116
	gint max_total_items;

	GtkWidget *status_section;
	GtkWidget *system_section;

Jim Krehl's avatar
Jim Krehl committed
117 118
	BookmarkAgent *bm_agents [BOOKMARK_STORE_N_TYPES];

Jim Krehl's avatar
Jim Krehl committed
119 120 121
	GnomeVFSVolumeMonitor *volume_mon;
	GList                 *mounts;

122 123 124 125 126 127 128 129 130 131 132 133
	guint search_cmd_gconf_mntr_id;
	guint current_page_gconf_mntr_id;
	guint more_link_vis_gconf_mntr_id;
	guint search_vis_gconf_mntr_id;
	guint status_vis_gconf_mntr_id;
	guint system_vis_gconf_mntr_id;
	guint showable_types_gconf_mntr_id;
	guint modifiable_system_gconf_mntr_id;
	guint modifiable_apps_gconf_mntr_id;
	guint modifiable_docs_gconf_mntr_id;
	guint modifiable_dirs_gconf_mntr_id;
	guint disable_term_gconf_mntr_id;
134 135
	guint disable_logout_gconf_mntr_id;
	guint disable_lockscreen_gconf_mntr_id;
136 137 138 139

	gboolean ptr_is_grabbed;
	gboolean kbd_is_grabbed;
} MainMenuUIPrivate;
Jim Krehl's avatar
Jim Krehl committed
140

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MAIN_MENU_UI_TYPE, MainMenuUIPrivate))

static void main_menu_ui_finalize (GObject *);

static void create_panel_button      (MainMenuUI *);
static void create_slab_window       (MainMenuUI *);
static void create_search_section    (MainMenuUI *);
static void create_file_section      (MainMenuUI *);
static void create_user_apps_section (MainMenuUI *);
static void create_rct_apps_section  (MainMenuUI *);
static void create_user_docs_section (MainMenuUI *);
static void create_rct_docs_section  (MainMenuUI *);
static void create_user_dirs_section (MainMenuUI *);
static void create_system_section    (MainMenuUI *);
static void create_status_section    (MainMenuUI *);
static void create_more_buttons      (MainMenuUI *);
static void setup_file_tables        (MainMenuUI *);
Jim Krehl's avatar
Jim Krehl committed
158
static void setup_bookmark_agents    (MainMenuUI *);
159 160
static void setup_lock_down          (MainMenuUI *);

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
static void       select_page                      (MainMenuUI *);
static void       update_limits                    (MainMenuUI *);
static void       connect_to_tile_triggers         (MainMenuUI *, TileTable *);
static void       hide_slab_if_urgent_close        (MainMenuUI *);
static void       set_search_section_visible       (MainMenuUI *);
static void       set_table_section_visible        (MainMenuUI *, TileTable *);
static gchar    **get_search_argv                  (const gchar *);
static void       reorient_panel_button            (MainMenuUI *);
static void       bind_beagle_search_key           (MainMenuUI *);
static void       launch_search                    (MainMenuUI *);
static void       grab_pointer_and_keyboard        (MainMenuUI *, guint32);
static void       apply_lockdown_settings          (MainMenuUI *);
static gboolean   app_is_in_blacklist              (const gchar *);
static void       toggle_panel_button              (MainMenuUI *);
static void       handle_panel_button_button_press (MainMenuUI *, guint64);
Jim Krehl's avatar
Jim Krehl committed
176 177 178 179 180 181 182 183 184

static Tile *item_to_user_app_tile   (BookmarkItem *, gpointer);
static Tile *item_to_recent_app_tile (BookmarkItem *, gpointer);
static Tile *item_to_user_doc_tile   (BookmarkItem *, gpointer);
static Tile *item_to_recent_doc_tile (BookmarkItem *, gpointer);
static Tile *item_to_dir_tile        (BookmarkItem *, gpointer);
static Tile *item_to_system_tile     (BookmarkItem *, gpointer);
static BookmarkItem *app_uri_to_item (const gchar *, gpointer);
static BookmarkItem *doc_uri_to_item (const gchar *, gpointer);
185

186
static void     panel_button_toggled_cb           (GtkToggleButton *, gpointer);
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
static gboolean panel_button_button_press_cb      (GtkWidget *, GdkEventButton *, gpointer);
static void     panel_button_drag_data_rcv_cb     (GtkWidget *, GdkDragContext *, gint, gint,
                                                   GtkSelectionData *, guint, guint, gpointer);
static gboolean slab_window_expose_cb             (GtkWidget *, GdkEventExpose *, gpointer);
static gboolean slab_window_key_press_cb          (GtkWidget *, GdkEventKey *, gpointer);
static gboolean slab_window_button_press_cb       (GtkWidget *, GdkEventButton *, gpointer);
static void     slab_window_allocate_cb           (GtkWidget *, GtkAllocation *, gpointer);
static void     slab_window_map_event_cb          (GtkWidget *, GdkEvent *, gpointer);
static void     slab_window_unmap_event_cb        (GtkWidget *, GdkEvent *, gpointer);
static gboolean slab_window_grab_broken_cb        (GtkWidget *, GdkEvent *, gpointer);
static void     search_entry_activate_cb          (GtkEntry *, gpointer);
static void     page_button_clicked_cb            (GtkButton *, gpointer);
static void     tile_table_notify_cb              (GObject *, GParamSpec *, gpointer);
static void     gtk_table_notify_cb               (GObject *, GParamSpec *, gpointer);
static void     tile_action_triggered_cb          (Tile *, TileEvent *, TileAction *, gpointer);
static void     more_buttons_clicked_cb            (GtkButton *, gpointer);
static void     search_cmd_notify_cb              (GConfClient *, guint, GConfEntry *, gpointer);
static void     current_page_notify_cb            (GConfClient *, guint, GConfEntry *, gpointer);
static void     lockdown_notify_cb                (GConfClient *, guint, GConfEntry *, gpointer);
static void     panel_menu_open_cb                (BonoboUIComponent *, gpointer, const gchar *);
static void     panel_menu_about_cb               (BonoboUIComponent *, gpointer, const gchar *);
static void     panel_applet_change_orient_cb     (PanelApplet *, PanelAppletOrient, gpointer);
static void     panel_applet_change_background_cb (PanelApplet *, PanelAppletBackgroundType, GdkColor *,
                                                   GdkPixmap * pixmap, gpointer);
static void     slab_window_tomboy_bindkey_cb     (gchar *, gpointer);
static void     search_tomboy_bindkey_cb          (gchar *, gpointer);
static gboolean grabbing_window_event_cb          (GtkWidget *, GdkEvent *, gpointer);
Jim Krehl's avatar
Jim Krehl committed
214 215
static void     user_app_agent_notify_cb          (GObject *, GParamSpec *, gpointer);
static void     user_doc_agent_notify_cb          (GObject *, GParamSpec *, gpointer);
Jim Krehl's avatar
Jim Krehl committed
216
static void     volume_monitor_mount_cb           (GnomeVFSVolumeMonitor *, GnomeVFSVolume *, gpointer);
217 218 219 220 221 222 223 224

static GdkFilterReturn slab_gdk_message_filter (GdkXEvent *, GdkEvent *, gpointer);

static const BonoboUIVerb applet_bonobo_verbs [] = {
	BONOBO_UI_UNSAFE_VERB ("MainMenuOpen",  panel_menu_open_cb),
	BONOBO_UI_UNSAFE_VERB ("MainMenuAbout", panel_menu_about_cb),
	BONOBO_UI_VERB_END
};
Jim Krehl's avatar
Jim Krehl committed
225

226
static const gchar *main_menu_authors [] = {
Jim Krehl's avatar
Jim Krehl committed
227 228 229 230 231 232
	"Jim Krehl <jimmyk@novell.com>",
	"Scott Reeves <sreeves@novell.com>",
	"Dan Winship <danw@novell.com>",
	NULL
};

233
static const gchar *main_menu_artists [] = {
Jim Krehl's avatar
Jim Krehl committed
234 235 236 237 238
	"Garrett LeSage <garrett@novell.com>",
	"Jakub Steiner <jimmac@novell.com>",
	NULL
};

239 240 241 242 243
enum {
	APPS_PAGE,
	DOCS_PAGE,
	DIRS_PAGE
};
Jim Krehl's avatar
Jim Krehl committed
244

245 246 247 248 249 250 251
enum {
	USER_APPS_TABLE,
	RCNT_APPS_TABLE,
	USER_DOCS_TABLE,
	RCNT_DOCS_TABLE,
	USER_DIRS_TABLE
};
Jim Krehl's avatar
Jim Krehl committed
252

253 254 255 256 257 258
enum {
	PANEL_BUTTON_ORIENT_TOP,
	PANEL_BUTTON_ORIENT_BOTTOM,
	PANEL_BUTTON_ORIENT_LEFT,
	PANEL_BUTTON_ORIENT_RIGHT
};
Jim Krehl's avatar
Jim Krehl committed
259

260
static Atom slab_action_main_menu_atom = None;
Jim Krehl's avatar
Jim Krehl committed
261

262 263 264 265 266
MainMenuUI *
main_menu_ui_new (PanelApplet *applet)
{
	MainMenuUI        *this;
	MainMenuUIPrivate *priv;
Jim Krehl's avatar
Jim Krehl committed
267

268
	gchar *glade_xml_path;
Jim Krehl's avatar
Jim Krehl committed
269 270


271 272
	this = g_object_new (MAIN_MENU_UI_TYPE, NULL);
	priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
273

274
	priv->panel_applet = applet;
Jim Krehl's avatar
Jim Krehl committed
275

276
	glade_xml_path = g_build_filename (DATADIR, PACKAGE, "slab-window.glade", NULL);
Jim Krehl's avatar
Jim Krehl committed
277

278 279
	priv->main_menu_xml    = glade_xml_new (glade_xml_path, "slab-main-menu-window", NULL);
	priv->panel_button_xml = glade_xml_new (glade_xml_path, "slab-panel-button-root", NULL);
280
	g_free (glade_xml_path);
Jim Krehl's avatar
Jim Krehl committed
281

Jim Krehl's avatar
Jim Krehl committed
282
	setup_bookmark_agents    (this);
283 284 285 286 287 288 289 290 291 292 293 294 295 296
	create_panel_button      (this);
	create_slab_window       (this);
	create_search_section    (this);
	create_file_section      (this);
	create_user_apps_section (this);
	create_rct_apps_section  (this);
	create_user_docs_section (this);
	create_rct_docs_section  (this);
	create_user_dirs_section (this);
	create_system_section    (this);
	create_status_section    (this);
	create_more_buttons      (this);
	setup_file_tables        (this);
	setup_lock_down          (this);
Jim Krehl's avatar
Jim Krehl committed
297

298 299 300 301
	bind_beagle_search_key  (this);
	update_limits           (this);
	select_page             (this);
	apply_lockdown_settings (this);
Jim Krehl's avatar
Jim Krehl committed
302

303 304
	return this;
}
Jim Krehl's avatar
Jim Krehl committed
305

306 307
static void
main_menu_ui_class_init (MainMenuUIClass *this_class)
308
{
309
	GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class);
Jim Krehl's avatar
Jim Krehl committed
310

311
	g_obj_class->finalize = main_menu_ui_finalize;
Jim Krehl's avatar
Jim Krehl committed
312

313 314
	g_type_class_add_private (this_class, sizeof (MainMenuUIPrivate));
}
Jim Krehl's avatar
Jim Krehl committed
315

316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
static void
main_menu_ui_init (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);

	priv->panel_applet                               = NULL;
	priv->panel_about_dialog                         = NULL;

	priv->main_menu_xml                              = NULL;
	priv->panel_button_xml                           = NULL;

	priv->panel_buttons [PANEL_BUTTON_ORIENT_TOP]    = NULL;
	priv->panel_buttons [PANEL_BUTTON_ORIENT_BOTTOM] = NULL;
	priv->panel_buttons [PANEL_BUTTON_ORIENT_LEFT]   = NULL;
	priv->panel_buttons [PANEL_BUTTON_ORIENT_RIGHT]  = NULL;
	priv->panel_button                               = NULL;

	priv->slab_window                                = NULL;

	priv->top_pane                                   = NULL;
	priv->left_pane                                  = NULL;

	priv->search_section                             = NULL;
	priv->search_entry                               = NULL;

	priv->file_section                               = NULL;
	priv->page_selectors [APPS_PAGE]                 = NULL;
	priv->page_selectors [DOCS_PAGE]                 = NULL;
	priv->page_selectors [DIRS_PAGE]                 = NULL;
	priv->notebook_page_ids [APPS_PAGE]              = 0;
	priv->notebook_page_ids [DOCS_PAGE]              = 0;
	priv->notebook_page_ids [DIRS_PAGE]              = 0;

	priv->file_tables [USER_APPS_TABLE]              = NULL;
	priv->file_tables [RCNT_APPS_TABLE]              = NULL;
	priv->file_tables [USER_DOCS_TABLE]              = NULL;
	priv->file_tables [RCNT_DOCS_TABLE]              = NULL;
	priv->file_tables [USER_DIRS_TABLE]              = NULL;
	priv->table_sections [USER_APPS_TABLE]           = NULL;
	priv->table_sections [RCNT_APPS_TABLE]           = NULL;
	priv->table_sections [USER_DOCS_TABLE]           = NULL;
	priv->table_sections [RCNT_DOCS_TABLE]           = NULL;
	priv->table_sections [USER_DIRS_TABLE]           = NULL;
	priv->allowable_types [USER_APPS_TABLE]          = TRUE;
	priv->allowable_types [RCNT_APPS_TABLE]          = TRUE;
	priv->allowable_types [USER_DOCS_TABLE]          = TRUE;
	priv->allowable_types [RCNT_DOCS_TABLE]          = TRUE;
	priv->allowable_types [USER_DIRS_TABLE]          = TRUE;

	priv->sys_table                                  = NULL;

	priv->more_buttons [APPS_PAGE]                   = NULL;
	priv->more_buttons [DOCS_PAGE]                   = NULL;
	priv->more_buttons [DIRS_PAGE]                   = NULL;
	priv->more_sections [APPS_PAGE]                  = NULL;
	priv->more_sections [DOCS_PAGE]                  = NULL;
	priv->more_sections [DIRS_PAGE]                  = NULL;

	priv->max_total_items                            = 8;

	priv->status_section                             = NULL;
	priv->system_section                             = NULL;

Jim Krehl's avatar
Jim Krehl committed
379 380
	priv->volume_mon                                 = NULL;

381 382 383 384 385 386 387 388 389 390 391 392
	priv->search_cmd_gconf_mntr_id                   = 0;
	priv->current_page_gconf_mntr_id                 = 0;
	priv->more_link_vis_gconf_mntr_id                = 0;
	priv->search_vis_gconf_mntr_id                   = 0;
	priv->status_vis_gconf_mntr_id                   = 0;
	priv->system_vis_gconf_mntr_id                   = 0;
	priv->showable_types_gconf_mntr_id               = 0;
	priv->modifiable_system_gconf_mntr_id            = 0;
	priv->modifiable_apps_gconf_mntr_id              = 0;
	priv->modifiable_docs_gconf_mntr_id              = 0;
	priv->modifiable_dirs_gconf_mntr_id              = 0;
	priv->disable_term_gconf_mntr_id                 = 0;
393 394
	priv->disable_logout_gconf_mntr_id               = 0;
	priv->disable_lockscreen_gconf_mntr_id           = 0;
395 396 397 398

	priv->ptr_is_grabbed                             = FALSE;
	priv->kbd_is_grabbed                             = FALSE;
}
Jim Krehl's avatar
Jim Krehl committed
399

400 401 402 403
static void
main_menu_ui_finalize (GObject *g_obj)
{
	MainMenuUIPrivate *priv = PRIVATE (g_obj);
Jim Krehl's avatar
Jim Krehl committed
404

405 406
	GConfClient *client;

407
	gint i;
Jim Krehl's avatar
Jim Krehl committed
408 409


410 411 412
	for (i = 0; i < 4; ++i) {
		g_object_unref (G_OBJECT (g_object_get_data (
			G_OBJECT (priv->more_buttons [i]), "double-click-detector")));
Jim Krehl's avatar
Jim Krehl committed
413

414 415
		g_object_unref (G_OBJECT (g_object_get_data (
			G_OBJECT (priv->panel_buttons [i]), "double-click-detector")));
Jim Krehl's avatar
Jim Krehl committed
416

417
		gtk_widget_unref (GTK_WIDGET (priv->panel_buttons [i]));
Jim Krehl's avatar
Jim Krehl committed
418 419
	}

420 421 422 423 424 425 426 427 428 429 430 431
	libslab_gconf_notify_remove (priv->search_cmd_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->current_page_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->more_link_vis_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->search_vis_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->status_vis_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->system_vis_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->showable_types_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->modifiable_system_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->modifiable_apps_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->modifiable_docs_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->modifiable_dirs_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->disable_term_gconf_mntr_id);
432 433 434 435 436 437
	libslab_gconf_notify_remove (priv->disable_logout_gconf_mntr_id);
	libslab_gconf_notify_remove (priv->disable_lockscreen_gconf_mntr_id);

	client  = gconf_client_get_default ();
	gconf_client_remove_dir (client, PANEL_LOCKDOWN_GCONF_DIR, NULL);
	g_object_unref (client);
438

Jim Krehl's avatar
Jim Krehl committed
439 440 441
	for (i = 0; i < BOOKMARK_STORE_N_TYPES; ++i)
		g_object_unref (priv->bm_agents [i]);

Jim Krehl's avatar
Jim Krehl committed
442 443 444 445
	g_list_foreach (priv->mounts, (GFunc) gnome_vfs_volume_unref, NULL);
	g_list_free (priv->mounts);
	gnome_vfs_volume_monitor_unref (priv->volume_mon);

446
	G_OBJECT_CLASS (main_menu_ui_parent_class)->finalize (g_obj);
Jim Krehl's avatar
Jim Krehl committed
447 448 449
}

static void
450
create_panel_button (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
451
{
452
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
453

454 455
	GtkWidget *button_root;
	GtkWidget *button_parent;
Jim Krehl's avatar
Jim Krehl committed
456

457
	gint i;
Jim Krehl's avatar
Jim Krehl committed
458 459


460 461
	button_root = glade_xml_get_widget (
		priv->panel_button_xml, "slab-panel-button-root");
Jim Krehl's avatar
Jim Krehl committed
462

463
	gtk_widget_hide (button_root);
Jim Krehl's avatar
Jim Krehl committed
464

465 466 467 468 469 470 471 472
	priv->panel_buttons [PANEL_BUTTON_ORIENT_TOP] = GTK_TOGGLE_BUTTON (glade_xml_get_widget (
		priv->panel_button_xml, "slab-main-menu-panel-button-top"));
	priv->panel_buttons [PANEL_BUTTON_ORIENT_BOTTOM] = GTK_TOGGLE_BUTTON (glade_xml_get_widget (
		priv->panel_button_xml, "slab-main-menu-panel-button-bottom"));
	priv->panel_buttons [PANEL_BUTTON_ORIENT_LEFT] = GTK_TOGGLE_BUTTON (glade_xml_get_widget (
		priv->panel_button_xml, "slab-main-menu-panel-button-left"));
	priv->panel_buttons [PANEL_BUTTON_ORIENT_RIGHT] = GTK_TOGGLE_BUTTON (glade_xml_get_widget (
		priv->panel_button_xml, "slab-main-menu-panel-button-right"));
Jim Krehl's avatar
Jim Krehl committed
473

474 475 476 477
	for (i = 0; i < 4; ++i) {
		g_object_set_data (
			G_OBJECT (priv->panel_buttons [i]), "double-click-detector",
			double_click_detector_new ());
Jim Krehl's avatar
Jim Krehl committed
478

479
		button_parent = gtk_widget_get_parent (GTK_WIDGET (priv->panel_buttons [i]));
Jim Krehl's avatar
Jim Krehl committed
480

481 482 483
		gtk_widget_ref (GTK_WIDGET (priv->panel_buttons [i]));
		gtk_container_remove (
			GTK_CONTAINER (button_parent), GTK_WIDGET (priv->panel_buttons [i]));
Jim Krehl's avatar
Jim Krehl committed
484

485
		g_signal_connect (
486 487
			G_OBJECT (priv->panel_buttons [i]), "toggled",
			G_CALLBACK (panel_button_toggled_cb), this);
Jim Krehl's avatar
Jim Krehl committed
488

489 490 491
		g_signal_connect (
			G_OBJECT (priv->panel_buttons [i]), "button_press_event",
			G_CALLBACK (panel_button_button_press_cb), this);
Jim Krehl's avatar
Jim Krehl committed
492

493 494 495 496
		gtk_drag_dest_set (
			GTK_WIDGET (priv->panel_buttons [i]),
			GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY | GDK_ACTION_MOVE);
		gtk_drag_dest_add_uri_targets (GTK_WIDGET (priv->panel_buttons [i]));
Jim Krehl's avatar
Jim Krehl committed
497

498 499 500 501
		g_signal_connect (
			G_OBJECT (priv->panel_buttons [i]), "drag-data-received",
			G_CALLBACK (panel_button_drag_data_rcv_cb), this);
	}
Jim Krehl's avatar
Jim Krehl committed
502

503
	gtk_widget_destroy (button_root);
Jim Krehl's avatar
Jim Krehl committed
504

505
	panel_applet_set_flags (priv->panel_applet, PANEL_APPLET_EXPAND_MINOR);
506

507
	reorient_panel_button (this);
Jim Krehl's avatar
Jim Krehl committed
508

509 510 511
	panel_applet_setup_menu_from_file (
		priv->panel_applet, NULL, "GNOME_MainMenu_ContextMenu.xml",
		NULL, applet_bonobo_verbs, this);
Jim Krehl's avatar
Jim Krehl committed
512

513 514 515 516 517 518 519
	g_signal_connect (
		G_OBJECT (priv->panel_applet), "change_orient",
		G_CALLBACK (panel_applet_change_orient_cb), this);

	g_signal_connect (
		G_OBJECT (priv->panel_applet), "change_background",
		G_CALLBACK (panel_applet_change_background_cb), this);
Jim Krehl's avatar
Jim Krehl committed
520 521
}

522 523
static void
create_slab_window (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
524
{
525
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
526

527
	GdkAtom slab_action_atom;
Jim Krehl's avatar
Jim Krehl committed
528 529


530 531 532 533 534
	priv->slab_window = glade_xml_get_widget (
		priv->main_menu_xml, "slab-main-menu-window");
	gtk_widget_set_app_paintable (priv->slab_window, TRUE);
	gtk_widget_hide              (priv->slab_window);
	gtk_window_stick             (GTK_WINDOW (priv->slab_window));
Jim Krehl's avatar
Jim Krehl committed
535

536 537
	priv->top_pane  = glade_xml_get_widget (priv->main_menu_xml, "top-pane");
	priv->left_pane = glade_xml_get_widget (priv->main_menu_xml, "left-pane");
Jim Krehl's avatar
Jim Krehl committed
538

539 540
	tomboy_keybinder_init ();
	tomboy_keybinder_bind ("<Ctrl>Escape", slab_window_tomboy_bindkey_cb, this);
Jim Krehl's avatar
Jim Krehl committed
541

542 543 544 545 546
	slab_action_atom = gdk_atom_intern ("_SLAB_ACTION", FALSE);
	slab_action_main_menu_atom = XInternAtom (
		GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "_SLAB_ACTION_MAIN_MENU", FALSE);
	gdk_display_add_client_message_filter (
		gdk_display_get_default (), slab_action_atom, slab_gdk_message_filter, this);
Jim Krehl's avatar
Jim Krehl committed
547

548 549 550
	g_signal_connect (
		G_OBJECT (priv->slab_window), "expose-event",
		G_CALLBACK (slab_window_expose_cb), this);
Jim Krehl's avatar
Jim Krehl committed
551

552 553 554
	g_signal_connect (
		G_OBJECT (priv->slab_window), "key-press-event",
		G_CALLBACK (slab_window_key_press_cb), this);
Jim Krehl's avatar
Jim Krehl committed
555

556 557 558
	g_signal_connect (
		G_OBJECT (priv->slab_window), "button-press-event",
		G_CALLBACK (slab_window_button_press_cb), this);
Jim Krehl's avatar
Jim Krehl committed
559

560 561 562
	g_signal_connect (
		G_OBJECT (priv->slab_window), "grab-broken-event",
		G_CALLBACK (slab_window_grab_broken_cb), this);
Jim Krehl's avatar
Jim Krehl committed
563

564 565 566
	g_signal_connect (
		G_OBJECT (priv->slab_window), "size-allocate",
		G_CALLBACK (slab_window_allocate_cb), this);
Jim Krehl's avatar
Jim Krehl committed
567

568 569 570
	g_signal_connect (
		G_OBJECT (priv->slab_window), "map-event",
		G_CALLBACK (slab_window_map_event_cb), this);
Jim Krehl's avatar
Jim Krehl committed
571

572 573 574
	g_signal_connect (
		G_OBJECT (priv->slab_window), "unmap-event",
		G_CALLBACK (slab_window_unmap_event_cb), this);
Jim Krehl's avatar
Jim Krehl committed
575 576 577
}

static void
578
create_search_section (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
579
{
580
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
581

582 583
        priv->search_section = glade_xml_get_widget (priv->main_menu_xml, "search-section");
	priv->search_entry   = glade_xml_get_widget (priv->main_menu_xml, "search-entry");
Jim Krehl's avatar
Jim Krehl committed
584

585 586 587
	g_signal_connect (
		G_OBJECT (priv->search_entry), "activate",
		G_CALLBACK (search_entry_activate_cb), this);
Jim Krehl's avatar
Jim Krehl committed
588

589
	set_search_section_visible (this);
Jim Krehl's avatar
Jim Krehl committed
590

591 592
	priv->search_cmd_gconf_mntr_id = libslab_gconf_notify_add (
		SEARCH_CMD_GCONF_KEY, search_cmd_notify_cb, this);
Jim Krehl's avatar
Jim Krehl committed
593 594 595
}

static void
596
create_file_section (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
597
{
598
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
599

600
	GtkWidget *pages [3];
Jim Krehl's avatar
Jim Krehl committed
601

602
	gint i;
Jim Krehl's avatar
Jim Krehl committed
603 604


605 606
	priv->file_section = GTK_NOTEBOOK (glade_xml_get_widget (
		priv->main_menu_xml, "file-area-notebook"));
Jim Krehl's avatar
Jim Krehl committed
607

608 609 610 611 612 613
	priv->page_selectors [APPS_PAGE] = glade_xml_get_widget (
		priv->main_menu_xml, "slab-page-selector-button-applications");
	priv->page_selectors [DOCS_PAGE] = glade_xml_get_widget (
		priv->main_menu_xml, "slab-page-selector-button-documents");
	priv->page_selectors [DIRS_PAGE] = glade_xml_get_widget (
		priv->main_menu_xml, "slab-page-selector-button-places");
Jim Krehl's avatar
Jim Krehl committed
614

615 616 617
	pages [APPS_PAGE] = glade_xml_get_widget (priv->main_menu_xml, "applications-page");
	pages [DOCS_PAGE] = glade_xml_get_widget (priv->main_menu_xml, "documents-page");
	pages [DIRS_PAGE] = glade_xml_get_widget (priv->main_menu_xml, "places-page");
Jim Krehl's avatar
Jim Krehl committed
618

619 620 621 622
	for (i = 0; i < 3; ++i) {
		gtk_container_child_get (
			GTK_CONTAINER (priv->file_section), pages [i],
			"position", & priv->notebook_page_ids [i], NULL);
Jim Krehl's avatar
Jim Krehl committed
623

624 625
		g_object_set_data (
			G_OBJECT (priv->page_selectors [i]), "page-type", GINT_TO_POINTER (i));
Jim Krehl's avatar
Jim Krehl committed
626

627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
		g_signal_connect (
			G_OBJECT (priv->page_selectors [i]), "clicked",
			G_CALLBACK (page_button_clicked_cb), this);
	}

	priv->current_page_gconf_mntr_id = libslab_gconf_notify_add (
		CURRENT_PAGE_GCONF_KEY, current_page_notify_cb, this);

	priv->table_sections [USER_APPS_TABLE] = glade_xml_get_widget (
		priv->main_menu_xml, "user-apps-section");
	priv->table_sections [RCNT_APPS_TABLE] = glade_xml_get_widget (
		priv->main_menu_xml, "recent-apps-section");
	priv->table_sections [USER_DOCS_TABLE] = glade_xml_get_widget (
		priv->main_menu_xml, "user-docs-section");
	priv->table_sections [RCNT_DOCS_TABLE] = glade_xml_get_widget (
		priv->main_menu_xml, "recent-docs-section");
	priv->table_sections [USER_DIRS_TABLE] = glade_xml_get_widget (
		priv->main_menu_xml, "user-dirs-section");
}
Jim Krehl's avatar
Jim Krehl committed
646

647 648 649 650
static void
create_system_section (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
651

652
	GtkContainer *ctnr;
Jim Krehl's avatar
Jim Krehl committed
653 654


655 656
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "system-item-table-container"));
Jim Krehl's avatar
Jim Krehl committed
657

Jim Krehl's avatar
Jim Krehl committed
658 659 660
	priv->sys_table = TILE_TABLE (tile_table_new (
		priv->bm_agents [BOOKMARK_STORE_SYSTEM], -1, 1, TRUE, TRUE,
		item_to_system_tile, this, app_uri_to_item, NULL));
Jim Krehl's avatar
Jim Krehl committed
661

662
	connect_to_tile_triggers (this, priv->sys_table);
Jim Krehl's avatar
Jim Krehl committed
663

664
	gtk_container_add (ctnr, GTK_WIDGET (priv->sys_table));
Jim Krehl's avatar
Jim Krehl committed
665

666 667 668
	g_signal_connect (
		G_OBJECT (priv->sys_table), "notify::" TILE_TABLE_TILES_PROP,
		G_CALLBACK (tile_table_notify_cb), this);
Jim Krehl's avatar
Jim Krehl committed
669

670 671 672
	priv->system_section = glade_xml_get_widget (
		priv->main_menu_xml, "slab-system-section");
}
Jim Krehl's avatar
Jim Krehl committed
673

674 675 676 677
static void
create_status_section (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
678

679 680
	GtkContainer *ctnr;
	GtkWidget    *tile;
Jim Krehl's avatar
Jim Krehl committed
681

682
	gint icon_width;
Jim Krehl's avatar
Jim Krehl committed
683 684


685 686 687
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "hard-drive-status-container"));
	tile = hard_drive_status_tile_new ();
Jim Krehl's avatar
Jim Krehl committed
688

689 690
	gtk_icon_size_lookup (GTK_ICON_SIZE_DND, & icon_width, NULL);
	gtk_widget_set_size_request (tile, 6 * icon_width, -1);
Jim Krehl's avatar
Jim Krehl committed
691

692 693 694
	g_signal_connect (
		G_OBJECT (tile), "tile-action-triggered",
		G_CALLBACK (tile_action_triggered_cb), this);
Jim Krehl's avatar
Jim Krehl committed
695

696 697
	gtk_container_add   (ctnr, tile);
	gtk_widget_show_all (GTK_WIDGET (ctnr));
Jim Krehl's avatar
Jim Krehl committed
698

699 700 701
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "network-status-container"));
	tile = network_status_tile_new ();
Jim Krehl's avatar
Jim Krehl committed
702

703
	gtk_widget_set_size_request (tile, 6 * icon_width, -1);
Jim Krehl's avatar
Jim Krehl committed
704

705 706 707
	g_signal_connect (
		G_OBJECT (tile), "tile-action-triggered",
		G_CALLBACK (tile_action_triggered_cb), this);
Jim Krehl's avatar
Jim Krehl committed
708

709 710
	gtk_container_add   (ctnr, tile);
	gtk_widget_show_all (GTK_WIDGET (ctnr));
Jim Krehl's avatar
Jim Krehl committed
711

712 713 714
	priv->status_section = glade_xml_get_widget (
		priv->main_menu_xml, "slab-status-section");
}
Jim Krehl's avatar
Jim Krehl committed
715

716 717 718 719
static void
create_user_apps_section (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
720

721
	GtkContainer *ctnr;
Jim Krehl's avatar
Jim Krehl committed
722 723


724 725
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "user-apps-table-container"));
Jim Krehl's avatar
Jim Krehl committed
726

Jim Krehl's avatar
Jim Krehl committed
727 728 729
	priv->file_tables [USER_APPS_TABLE] = TILE_TABLE (tile_table_new (
		priv->bm_agents [BOOKMARK_STORE_USER_APPS], -1, 2, TRUE, TRUE,
		item_to_user_app_tile, this, app_uri_to_item, NULL));
Jim Krehl's avatar
Jim Krehl committed
730

731 732
	gtk_container_add (ctnr, GTK_WIDGET (priv->file_tables [USER_APPS_TABLE]));
}
Jim Krehl's avatar
Jim Krehl committed
733

734 735 736 737
static void
create_rct_apps_section (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
738

739
	GtkContainer *ctnr;
Jim Krehl's avatar
Jim Krehl committed
740 741


742 743
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "recent-apps-table-container"));
Jim Krehl's avatar
Jim Krehl committed
744

Jim Krehl's avatar
Jim Krehl committed
745 746 747
	priv->file_tables [RCNT_APPS_TABLE] = TILE_TABLE (tile_table_new (
		priv->bm_agents [BOOKMARK_STORE_RECENT_APPS], -1, 2, FALSE, FALSE,
		item_to_recent_app_tile, this, NULL, NULL));
Jim Krehl's avatar
Jim Krehl committed
748

749
	gtk_container_add (ctnr, GTK_WIDGET (priv->file_tables [RCNT_APPS_TABLE]));
Jim Krehl's avatar
Jim Krehl committed
750 751 752
}

static void
753
create_user_docs_section (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
754
{
755
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
756

757
	GtkContainer *ctnr;
Jim Krehl's avatar
Jim Krehl committed
758 759


760 761
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "user-docs-table-container"));
Jim Krehl's avatar
Jim Krehl committed
762

Jim Krehl's avatar
Jim Krehl committed
763 764 765
	priv->file_tables [USER_DOCS_TABLE] = TILE_TABLE (tile_table_new (
		priv->bm_agents [BOOKMARK_STORE_USER_DOCS], -1, 2, TRUE, TRUE,
		item_to_user_doc_tile, this, doc_uri_to_item, NULL));
Jim Krehl's avatar
Jim Krehl committed
766

767
	gtk_container_add (ctnr, GTK_WIDGET (priv->file_tables [USER_DOCS_TABLE]));
Jim Krehl's avatar
Jim Krehl committed
768 769 770
}

static void
771
create_rct_docs_section (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
772
{
773
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
774

775
	GtkContainer *ctnr;
Jim Krehl's avatar
Jim Krehl committed
776 777


778 779
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "recent-docs-table-container"));
Jim Krehl's avatar
Jim Krehl committed
780

Jim Krehl's avatar
Jim Krehl committed
781 782 783
	priv->file_tables [RCNT_DOCS_TABLE] = TILE_TABLE (tile_table_new (
		priv->bm_agents [BOOKMARK_STORE_RECENT_DOCS], -1, 2, FALSE, FALSE,
		item_to_recent_doc_tile, this, NULL, NULL));
Jim Krehl's avatar
Jim Krehl committed
784

785
	gtk_container_add (ctnr, GTK_WIDGET (priv->file_tables [RCNT_DOCS_TABLE]));
Jim Krehl's avatar
Jim Krehl committed
786 787 788 789 790 791

	priv->volume_mon = gnome_vfs_get_volume_monitor ();
	priv->mounts = gnome_vfs_volume_monitor_get_mounted_volumes (priv->volume_mon);

	g_signal_connect (priv->volume_mon, "volume_mounted", G_CALLBACK (volume_monitor_mount_cb), this);
	g_signal_connect (priv->volume_mon, "volume_unmounted", G_CALLBACK (volume_monitor_mount_cb), this);
792
}
Jim Krehl's avatar
Jim Krehl committed
793

794 795 796 797
static void
create_user_dirs_section (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
798

799
	GtkContainer *ctnr;
Jim Krehl's avatar
Jim Krehl committed
800 801


802 803
	ctnr = GTK_CONTAINER (glade_xml_get_widget (
		priv->main_menu_xml, "user-dirs-table-container"));
Jim Krehl's avatar
Jim Krehl committed
804

Jim Krehl's avatar
Jim Krehl committed
805 806 807
	priv->file_tables [USER_DIRS_TABLE] = TILE_TABLE (tile_table_new (
		priv->bm_agents [BOOKMARK_STORE_USER_DIRS], -1, 2, FALSE, FALSE,
		item_to_dir_tile, this, NULL, NULL));
Jim Krehl's avatar
Jim Krehl committed
808

809 810
	gtk_container_add (ctnr, GTK_WIDGET (priv->file_tables [USER_DIRS_TABLE]));
}
Jim Krehl's avatar
Jim Krehl committed
811

812 813 814 815
static void
create_more_buttons (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
816

817
	gint i;
Jim Krehl's avatar
Jim Krehl committed
818 819


820 821 822
	priv->more_buttons [0] = glade_xml_get_widget (priv->main_menu_xml, "more-applications-button");
	priv->more_buttons [1] = glade_xml_get_widget (priv->main_menu_xml, "more-documents-button");
	priv->more_buttons [2] = glade_xml_get_widget (priv->main_menu_xml, "more-places-button");
Jim Krehl's avatar
Jim Krehl committed
823

824 825 826 827
	for (i = 0; i < 3; ++i) {
		g_object_set_data (
			G_OBJECT (priv->more_buttons [i]),
			"double-click-detector", double_click_detector_new ());
Jim Krehl's avatar
Jim Krehl committed
828

829 830 831
		g_signal_connect (
			G_OBJECT (priv->more_buttons [i]), "clicked",
			G_CALLBACK (more_buttons_clicked_cb), this);
Jim Krehl's avatar
Jim Krehl committed
832 833
	}

834 835 836
	priv->more_sections [0] = glade_xml_get_widget (priv->main_menu_xml, "more-apps-section");
	priv->more_sections [1] = glade_xml_get_widget (priv->main_menu_xml, "more-docs-section");
	priv->more_sections [2] = glade_xml_get_widget (priv->main_menu_xml, "more-dirs-section");
Jim Krehl's avatar
Jim Krehl committed
837 838
}

839 840
static void
setup_file_tables (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
841
{
842
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
843

844
	GList *tiles;
Jim Krehl's avatar
Jim Krehl committed
845

846
	gint i;
Jim Krehl's avatar
Jim Krehl committed
847 848


849 850 851 852
	for (i = 0; i < 5; ++i) {
		g_object_set_data (G_OBJECT (priv->file_tables [i]), "table-id", GINT_TO_POINTER (i));
		gtk_table_set_row_spacings (GTK_TABLE (priv->file_tables [i]), 6);
		gtk_table_set_col_spacings (GTK_TABLE (priv->file_tables [i]), 6);
Jim Krehl's avatar
Jim Krehl committed
853

854
		connect_to_tile_triggers (this, priv->file_tables [i]);
Jim Krehl's avatar
Jim Krehl committed
855

856
		g_object_get (G_OBJECT (priv->file_tables [i]), TILE_TABLE_TILES_PROP, & tiles, NULL);
Jim Krehl's avatar
Jim Krehl committed
857

858 859
		if (g_list_length (tiles) <= 0)
			gtk_widget_hide (priv->table_sections [i]);
Jim Krehl's avatar
Jim Krehl committed
860

861 862 863
		g_signal_connect (
			G_OBJECT (priv->file_tables [i]), "notify::" TILE_TABLE_TILES_PROP,
			G_CALLBACK (tile_table_notify_cb), this);
Jim Krehl's avatar
Jim Krehl committed
864

865 866 867
		g_signal_connect (
			G_OBJECT (priv->file_tables [i]), "notify::n-rows",
			G_CALLBACK (gtk_table_notify_cb), this);
Jim Krehl's avatar
Jim Krehl committed
868 869 870
	}
}

Jim Krehl's avatar
Jim Krehl committed
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
static void
setup_bookmark_agents (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);
	gint i;

	for (i = 0; i < BOOKMARK_STORE_N_TYPES; ++i) {
		priv->bm_agents [i] = bookmark_agent_get_instance (i);

		if (i == BOOKMARK_STORE_USER_APPS || i == BOOKMARK_STORE_SYSTEM)
			g_signal_connect (
				G_OBJECT (priv->bm_agents [i]), "notify::" BOOKMARK_AGENT_ITEMS_PROP,
				G_CALLBACK (user_app_agent_notify_cb), this);
		else if (i == BOOKMARK_STORE_USER_DOCS)
			g_signal_connect (
				G_OBJECT (priv->bm_agents [i]), "notify::" BOOKMARK_AGENT_ITEMS_PROP,
				G_CALLBACK (user_doc_agent_notify_cb), this);
	}
}

Jim Krehl's avatar
Jim Krehl committed
891
static void
892
setup_lock_down (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
893
{
894 895
	MainMenuUIPrivate *priv = PRIVATE (this);

896 897 898 899 900 901
	GConfClient *client;

	client = gconf_client_get_default ();
	gconf_client_add_dir (client, PANEL_LOCKDOWN_GCONF_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
	g_object_unref (client);

902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
	priv->more_link_vis_gconf_mntr_id = libslab_gconf_notify_add (
		MORE_LINK_VIS_GCONF_KEY, lockdown_notify_cb, this);
	priv->search_vis_gconf_mntr_id = libslab_gconf_notify_add (
		SEARCH_VIS_GCONF_KEY, lockdown_notify_cb, this);
	priv->status_vis_gconf_mntr_id = libslab_gconf_notify_add (
		STATUS_VIS_GCONF_KEY, lockdown_notify_cb, this);
	priv->system_vis_gconf_mntr_id = libslab_gconf_notify_add (
		SYSTEM_VIS_GCONF_KEY, lockdown_notify_cb, this);
	priv->showable_types_gconf_mntr_id = libslab_gconf_notify_add (
		SHOWABLE_TYPES_GCONF_KEY, lockdown_notify_cb, this);
	priv->modifiable_system_gconf_mntr_id = libslab_gconf_notify_add (
		MODIFIABLE_SYSTEM_GCONF_KEY, lockdown_notify_cb, this);
	priv->modifiable_apps_gconf_mntr_id = libslab_gconf_notify_add (
		MODIFIABLE_APPS_GCONF_KEY, lockdown_notify_cb, this);
	priv->modifiable_docs_gconf_mntr_id = libslab_gconf_notify_add (
		MODIFIABLE_DOCS_GCONF_KEY, lockdown_notify_cb, this);
	priv->modifiable_dirs_gconf_mntr_id = libslab_gconf_notify_add (
		MODIFIABLE_DIRS_GCONF_KEY, lockdown_notify_cb, this);
	priv->disable_term_gconf_mntr_id = libslab_gconf_notify_add (
		DISABLE_TERMINAL_GCONF_KEY, lockdown_notify_cb, this);
922 923 924 925
	priv->disable_logout_gconf_mntr_id = libslab_gconf_notify_add (
		DISABLE_LOGOUT_GCONF_KEY, lockdown_notify_cb, this);
	priv->disable_lockscreen_gconf_mntr_id = libslab_gconf_notify_add (
		DISABLE_LOCKSCREEN_GCONF_KEY, lockdown_notify_cb, this);
Jim Krehl's avatar
Jim Krehl committed
926 927
}

Jim Krehl's avatar
Jim Krehl committed
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
static Tile *
item_to_user_app_tile (BookmarkItem *item, gpointer data)
{
	if (app_is_in_blacklist (item->uri))
		return NULL;

	return TILE (application_tile_new (item->uri));
}

static Tile *
item_to_recent_app_tile (BookmarkItem *item, gpointer data)
{
	MainMenuUIPrivate *priv = PRIVATE (data);

	Tile *tile = NULL;

	gboolean blacklisted;


	blacklisted =
		bookmark_agent_has_item (priv->bm_agents [BOOKMARK_STORE_SYSTEM],    item->uri) ||
		bookmark_agent_has_item (priv->bm_agents [BOOKMARK_STORE_USER_APPS], item->uri) ||
		app_is_in_blacklist (item->uri);

	if (! blacklisted)
		tile = TILE (application_tile_new (item->uri));

	return tile;
}

static Tile *
item_to_user_doc_tile (BookmarkItem *item, gpointer data)
{
	return TILE (document_tile_new (item->uri, item->mime_type, item->mtime));
}

static Tile *
item_to_recent_doc_tile (BookmarkItem *item, gpointer data)
{
	MainMenuUIPrivate *priv = PRIVATE (data);

Jim Krehl's avatar
Jim Krehl committed
969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997
	GnomeVFSVolume *vol;
	gboolean        is_nfs = FALSE;
	GnomeVFSURI    *gvfs_uri;
	gboolean        is_local = TRUE;

	GList *node;


	if (! g_str_has_prefix (item->uri, "file://"))
		return NULL;

	for (node = priv->mounts; ! is_nfs && node; node = node->next) {
		vol = (GnomeVFSVolume *) node->data;

		is_nfs =
			((gnome_vfs_volume_get_device_type (vol) == GNOME_VFS_DEVICE_TYPE_NFS) &&
			g_str_has_prefix (item->uri, gnome_vfs_volume_get_activation_uri (vol)));
	}

	if (is_nfs)
		return NULL;

	gvfs_uri = gnome_vfs_uri_new (item->uri);
	is_local = gnome_vfs_uri_is_local (gvfs_uri);
	gnome_vfs_uri_unref (gvfs_uri);

	if (! is_local)
		return NULL;

Jim Krehl's avatar
Jim Krehl committed
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
	if (bookmark_agent_has_item (priv->bm_agents [BOOKMARK_STORE_USER_DOCS], item->uri))
		return NULL;

	return TILE (document_tile_new (item->uri, item->mime_type, item->mtime));
}

static Tile *
item_to_dir_tile (BookmarkItem *item, gpointer data)
{
	return TILE (directory_tile_new (item->uri, item->title, item->icon));
}

static Tile *
item_to_system_tile (BookmarkItem *item, gpointer data)
{
	if (app_is_in_blacklist (item->uri))
		return NULL;

	return TILE (system_tile_new (item->uri, item->title));
}

static BookmarkItem *
app_uri_to_item (const gchar *uri, gpointer data)
{
	BookmarkItem *item = g_new0 (BookmarkItem, 1);

	item->uri       = g_strdup (uri);
	item->mime_type = g_strdup ("application/x-desktop");

	return item;
}

static BookmarkItem *
doc_uri_to_item (const gchar *uri, gpointer data)
{
	BookmarkItem *item;

	GnomeVFSFileInfo        *info;
	GnomeVFSMimeApplication *default_app;


	item = g_new0 (BookmarkItem, 1);

	item->uri = g_strdup (uri);

	info = gnome_vfs_file_info_new ();

	gnome_vfs_get_file_info (
		item->uri, info, 
		GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE);

	item->mime_type = g_strdup (info->mime_type);
	item->mtime     = info->mtime;

	if (item->mime_type) {
		default_app = gnome_vfs_mime_get_default_application (item->mime_type);

		item->app_name = g_strdup (gnome_vfs_mime_application_get_name (default_app));
		item->app_exec = g_strdup (gnome_vfs_mime_application_get_exec (default_app));

		gnome_vfs_mime_application_free (default_app);
	}

	gnome_vfs_file_info_unref (info);

	if (! (item->mime_type && item->app_name)) {
		bookmark_item_free (item);
		item = NULL;
	}

	return item;
}

static gboolean
app_is_in_blacklist (const gchar *uri)
{
	GList *blacklist;

	gboolean disable_term;
1077 1078 1079
	gboolean disable_logout;
	gboolean disable_lockscreen;

Jim Krehl's avatar
Jim Krehl committed
1080 1081 1082 1083 1084 1085 1086 1087
	gboolean blacklisted;

	GList *node;


	disable_term = GPOINTER_TO_INT (libslab_get_gconf_value (DISABLE_TERMINAL_GCONF_KEY));
	blacklisted  = disable_term && libslab_desktop_item_is_a_terminal (uri);

1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099
	if (blacklisted)
		return TRUE;

	disable_logout = GPOINTER_TO_INT (libslab_get_gconf_value (DISABLE_LOGOUT_GCONF_KEY));
	blacklisted    = disable_logout && libslab_desktop_item_is_logout (uri);

	if (blacklisted)
		return TRUE;

	disable_lockscreen = GPOINTER_TO_INT (libslab_get_gconf_value (DISABLE_LOCKSCREEN_GCONF_KEY));
	blacklisted        = disable_lockscreen && libslab_desktop_item_is_lockscreen (uri);

Jim Krehl's avatar
Jim Krehl committed
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
	if (blacklisted)
		return TRUE;

	blacklist = libslab_get_gconf_value (APP_BLACKLIST_GCONF_KEY);

	for (node = blacklist; node; node = node->next) {
		if (! blacklisted && strstr (uri, (gchar *) node->data))
			blacklisted = TRUE;

		g_free (node->data);
	}

	g_list_free (blacklist);

	return blacklisted;
}

1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
static void
toggle_panel_button (MainMenuUI *this)
{
	MainMenuUIPrivate *priv = PRIVATE (this);

	gboolean active = gtk_toggle_button_get_active (priv->panel_button);

	gtk_toggle_button_set_active (priv->panel_button, ! active);
}

static void
handle_panel_button_button_press (MainMenuUI *this, guint64 time)
{
	MainMenuUIPrivate *priv = PRIVATE (this);

	DoubleClickDetector *dcd;
	gboolean             is_dc;

	dcd = DOUBLE_CLICK_DETECTOR (
		g_object_get_data (G_OBJECT (priv->panel_button),
			"double-click-detector"));

	is_dc = double_click_detector_is_double_click (dcd, time, TRUE);

	if (! is_dc)
		toggle_panel_button (this);
}

1145 1146
static void
select_page (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
1147
{
1148
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
1149

1150 1151
	GtkToggleButton *button;
	gint curr_page;
Jim Krehl's avatar
Jim Krehl committed
1152 1153


1154 1155
	curr_page = GPOINTER_TO_INT (libslab_get_gconf_value (CURRENT_PAGE_GCONF_KEY));
	button    = GTK_TOGGLE_BUTTON (priv->page_selectors [curr_page]);
Jim Krehl's avatar
Jim Krehl committed
1156

1157
	gtk_toggle_button_set_active (button, TRUE);
Jim Krehl's avatar
Jim Krehl committed
1158 1159 1160
}

static void
1161
update_limits (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
1162
{
1163
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
1164

1165 1166 1167 1168 1169 1170 1171
	GObject   *user_tables   [2];
	GObject   *recent_tables [2];
	gint       n_user_bins   [2];
	GtkWidget *sections      [2];

	gint n_rows;
	gint n_cols;
Jim Krehl's avatar
Jim Krehl committed
1172

1173 1174 1175
	gint max_total_items_default;
	gint max_total_items_new;
	gint min_recent_items;
Jim Krehl's avatar
Jim Krehl committed
1176 1177 1178 1179

	gint i;


1180 1181
	user_tables [0] = G_OBJECT (priv->file_tables [USER_APPS_TABLE]);
	user_tables [1] = G_OBJECT (priv->file_tables [USER_DOCS_TABLE]);
Jim Krehl's avatar
Jim Krehl committed
1182

1183 1184
	recent_tables [0] = G_OBJECT (priv->file_tables [RCNT_APPS_TABLE]);
	recent_tables [1] = G_OBJECT (priv->file_tables [RCNT_DOCS_TABLE]);
Jim Krehl's avatar
Jim Krehl committed
1185

1186 1187
	sections [0] = priv->table_sections [USER_APPS_TABLE];
	sections [1] = priv->table_sections [USER_DOCS_TABLE];
Jim Krehl's avatar
Jim Krehl committed
1188

1189
/* TODO: make this instant apply */
Jim Krehl's avatar
Jim Krehl committed
1190

1191 1192 1193 1194
	max_total_items_default = GPOINTER_TO_INT (
		libslab_get_gconf_value (MAX_TOTAL_ITEMS_GCONF_KEY));
	min_recent_items = GPOINTER_TO_INT (
		libslab_get_gconf_value (MIN_RECENT_ITEMS_GCONF_KEY));
Jim Krehl's avatar
Jim Krehl committed
1195

1196
	priv->max_total_items = max_total_items_default;
Jim Krehl's avatar
Jim Krehl committed
1197

1198 1199 1200 1201 1202 1203 1204
	for (i = 0; i < 2; ++i) {
		if (GTK_WIDGET_VISIBLE (sections [i]))
			g_object_get (
				user_tables [i],
				"n-rows", & n_rows, "n-columns", & n_cols, NULL);
		else
			n_rows = n_cols = 0;
Jim Krehl's avatar
Jim Krehl committed
1205

1206
		n_user_bins [i] = n_cols * n_rows;
Jim Krehl's avatar
Jim Krehl committed
1207

1208 1209 1210 1211
		max_total_items_new = n_user_bins [i] + min_recent_items;

		if (priv->max_total_items < max_total_items_new)
			priv->max_total_items = max_total_items_new;
Jim Krehl's avatar
Jim Krehl committed
1212 1213
	}

1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225
	g_object_get (
		priv->file_tables [USER_DIRS_TABLE],
		"n-rows", & n_rows, "n-columns", & n_cols, NULL);

	if (priv->max_total_items < (n_rows * n_cols))
		priv->max_total_items = n_rows * n_cols;

	for (i = 0; i < 2; ++i)
		g_object_set (
			recent_tables [i],
			TILE_TABLE_LIMIT_PROP, priv->max_total_items - n_user_bins [i],
			NULL);
Jim Krehl's avatar
Jim Krehl committed
1226 1227
}

1228 1229
static void
connect_to_tile_triggers (MainMenuUI *this, TileTable *table)
Jim Krehl's avatar
Jim Krehl committed
1230
{
1231 1232
	GList *tiles;
	GList *node;
Jim Krehl's avatar
Jim Krehl committed
1233

1234
	gulong handler_id;
Jim Krehl's avatar
Jim Krehl committed
1235

1236
	gint icon_width;
Jim Krehl's avatar
Jim Krehl committed
1237 1238


1239
	g_object_get (G_OBJECT (table), TILE_TABLE_TILES_PROP, & tiles, NULL);
Jim Krehl's avatar
Jim Krehl committed
1240

1241 1242 1243 1244
	for (node = tiles; node; node = node->next) {
		handler_id = g_signal_handler_find (
			G_OBJECT (node->data), G_SIGNAL_MATCH_FUNC, 0, 0,
			NULL, tile_action_triggered_cb, NULL);
Jim Krehl's avatar
Jim Krehl committed
1245

1246 1247 1248 1249
		if (! handler_id)
			g_signal_connect (
				G_OBJECT (node->data), "tile-action-triggered",
				G_CALLBACK (tile_action_triggered_cb), this);
Jim Krehl's avatar
Jim Krehl committed
1250

1251 1252 1253 1254

		gtk_icon_size_lookup (GTK_ICON_SIZE_DND, & icon_width, NULL);
		gtk_widget_set_size_request (GTK_WIDGET (node->data), 6 * icon_width, -1);
	}
Jim Krehl's avatar
Jim Krehl committed
1255 1256 1257
}

static void
1258
hide_slab_if_urgent_close (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
1259
{
1260
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
1261

1262 1263
	if (! GPOINTER_TO_INT (libslab_get_gconf_value (URGENT_CLOSE_GCONF_KEY)))
		return;
Jim Krehl's avatar
Jim Krehl committed
1264

1265
	gtk_toggle_button_set_active (priv->panel_button, FALSE);
Jim Krehl's avatar
Jim Krehl committed
1266 1267 1268
}

static void
1269
set_search_section_visible (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
1270
{
1271
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
1272

1273 1274
	gboolean allowable;
	gboolean visible;
Jim Krehl's avatar
Jim Krehl committed
1275

1276 1277
	gchar **argv;
	gchar  *found_cmd = NULL;
Jim Krehl's avatar
Jim Krehl committed
1278 1279


1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290
	allowable = GPOINTER_TO_INT (libslab_get_gconf_value (SEARCH_VIS_GCONF_KEY));

	if (allowable) {
		argv = get_search_argv (NULL);
		found_cmd = g_find_program_in_path (argv [0]);

		visible = (found_cmd != NULL);

		g_strfreev (argv);
		g_free (found_cmd);
	}
Jim Krehl's avatar
Jim Krehl committed
1291
	else
1292 1293 1294 1295 1296 1297
		visible = FALSE;

	if (visible)
		gtk_widget_show (priv->search_section);
	else
		gtk_widget_hide (priv->search_section);
Jim Krehl's avatar
Jim Krehl committed
1298 1299 1300
}

static void
1301
set_table_section_visible (MainMenuUI *this, TileTable *table)
Jim Krehl's avatar
Jim Krehl committed
1302
{
1303
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
1304

1305 1306
	gint   table_id;
	GList *tiles;
Jim Krehl's avatar
Jim Krehl committed
1307 1308


1309 1310
	table_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (table), "table-id"));
	g_object_get (G_OBJECT (table), TILE_TABLE_TILES_PROP, & tiles, NULL);
Jim Krehl's avatar
Jim Krehl committed
1311

1312 1313 1314 1315
	if (priv->allowable_types [table_id] && g_list_length (tiles) > 0)
		gtk_widget_show (priv->table_sections [table_id]);
	else
		gtk_widget_hide (priv->table_sections [table_id]);
Jim Krehl's avatar
Jim Krehl committed
1316

1317 1318 1319 1320 1321 1322 1323
	if (
		GTK_WIDGET_VISIBLE (priv->table_sections [USER_APPS_TABLE]) ||
		GTK_WIDGET_VISIBLE (priv->table_sections [RCNT_APPS_TABLE])
	)
		gtk_widget_show (priv->page_selectors [APPS_PAGE]);
	else
		gtk_widget_hide (priv->page_selectors [APPS_PAGE]);
Jim Krehl's avatar
Jim Krehl committed
1324

1325 1326 1327 1328 1329 1330 1331
	if (
		GTK_WIDGET_VISIBLE (priv->table_sections [USER_DOCS_TABLE]) ||
		GTK_WIDGET_VISIBLE (priv->table_sections [RCNT_DOCS_TABLE])
	)
		gtk_widget_show (priv->page_selectors [DOCS_PAGE]);
	else
		gtk_widget_hide (priv->page_selectors [DOCS_PAGE]);
Jim Krehl's avatar
Jim Krehl committed
1332

1333 1334 1335 1336 1337
	if (GTK_WIDGET_VISIBLE (priv->table_sections [USER_DIRS_TABLE]))
		gtk_widget_show (priv->page_selectors [DIRS_PAGE]);
	else
		gtk_widget_hide (priv->page_selectors [DIRS_PAGE]);
}
Jim Krehl's avatar
Jim Krehl committed
1338

1339 1340 1341 1342 1343 1344
static gchar **
get_search_argv (const gchar *search_txt)
{
	gchar  *cmd;
	gint    argc;
	gchar **argv_parsed = NULL;
Jim Krehl's avatar
Jim Krehl committed
1345

1346
	gchar **argv = NULL;
Jim Krehl's avatar
Jim Krehl committed
1347

1348
	gint i;
Jim Krehl's avatar
Jim Krehl committed
1349 1350


1351
	cmd = (gchar *) libslab_get_gconf_value (SEARCH_CMD_GCONF_KEY);
Jim Krehl's avatar
Jim Krehl committed
1352

1353 1354
	if (! cmd) {
		g_warning ("could not find search command in gconf [" SEARCH_CMD_GCONF_KEY "]\n");
Jim Krehl's avatar
Jim Krehl committed
1355

1356 1357
		return NULL;
	}
Jim Krehl's avatar
Jim Krehl committed
1358

1359 1360
	if (! g_shell_parse_argv (cmd, & argc, & argv_parsed, NULL))
		goto exit;
Jim Krehl's avatar
Jim Krehl committed
1361

1362
	argv = g_new0 (gchar *, argc + 1);
Jim Krehl's avatar
Jim Krehl committed
1363

1364 1365 1366 1367 1368
	for (i = 0; i < argc; ++i) {
		if (! strcmp (argv_parsed [i], "SEARCH_STRING"))
			argv [i] = g_strdup ((search_txt == NULL) ? "" : search_txt);
		else
			argv [i] = g_strdup (argv_parsed [i]);
Jim Krehl's avatar
Jim Krehl committed
1369 1370
	}

1371
	argv [argc] = NULL;
Jim Krehl's avatar
Jim Krehl committed
1372

1373
exit:
Jim Krehl's avatar
Jim Krehl committed
1374

1375 1376
	g_free (cmd);
	g_strfreev (argv_parsed);
Jim Krehl's avatar
Jim Krehl committed
1377

1378
	return argv;
Jim Krehl's avatar
Jim Krehl committed
1379 1380
}

1381 1382
static void
reorient_panel_button (MainMenuUI *this)
Jim Krehl's avatar
Jim Krehl committed
1383
{
1384
	MainMenuUIPrivate *priv = PRIVATE (this);
Jim Krehl's avatar
Jim Krehl committed
1385

1386
	PanelAppletOrient orientation;
Jim Krehl's avatar
Jim Krehl committed
1387

1388
	GtkWidget *child;
Jim Krehl's avatar
Jim Krehl committed
1389 1390


1391
	orientation = panel_applet_get_orient (priv->panel_applet);
Jim Krehl's avatar
Jim Krehl committed
1392

1393
	child = gtk_bin_get_child (GTK_BIN (priv->panel_applet));
1394

1395 1396
	if (GTK_IS_WIDGET (child))
		gtk_container_remove (GTK_CONTAINER (priv->panel_applet), child);
Jim Krehl's avatar
Jim Krehl committed
1397

1398 1399 1400 1401
	switch (orientation) {
		case PANEL_APPLET_ORIENT_LEFT:
			priv->panel_button = priv->panel_buttons [PANEL_BUTTON_ORIENT_RIGHT];
			break;
Jim Krehl's avatar
Jim Krehl committed
1402

1403 1404 1405
		case PANEL_APPLET_ORIENT_RIGHT:
			priv->panel_button = priv->panel_buttons [PANEL_BUTTON_ORIENT_LEFT];
			break;