Commit 7ca5dda8 authored by Vincent Untz's avatar Vincent Untz
Browse files

panel: Drop drawers

It's finally time to drop drawers:
 - there are always been various issues here and there, and they've
   never got fixed
 - it added complexity to the code
 - number of users using it is small
 - 3.0 is a good time to do this change
parent c1ab7e84
......@@ -32,7 +32,6 @@ panel_sources = \
panel-compatibility.c \
panel.c \
applet.c \
drawer.c \
panel-config-global.c \
panel-util.c \
panel-gconf.c \
......@@ -79,7 +78,6 @@ panel_headers = \
panel-compatibility.h \
panel.h \
applet.h \
drawer.h \
panel-util.h \
panel-properties-dialog.h \
panel-config-global.h \
......
......@@ -17,8 +17,8 @@
#include <libpanel-util/panel-show.h>
#include "button-widget.h"
#include "drawer.h"
#include "launcher.h"
#include "panel.h"
#include "panel-addto.h"
#include "panel-bindings.h"
#include "panel-gconf.h"
......@@ -42,6 +42,7 @@ static GSList *registered_applets = NULL;
static GSList *queued_position_saves = NULL;
static guint queued_position_source = 0;
static GtkWidget *panel_applet_get_menu (AppletInfo *info);
static void applet_menu_show (GtkWidget *w, AppletInfo *info);
static void applet_menu_deactivate (GtkWidget *w, AppletInfo *info);
......@@ -56,9 +57,6 @@ panel_applet_set_dnd_enabled (AppletInfo *info,
gboolean dnd_enabled)
{
switch (info->type) {
case PANEL_OBJECT_DRAWER:
panel_drawer_set_dnd_enabled (info->data, dnd_enabled);
break;
case PANEL_OBJECT_MENU:
panel_menu_button_set_dnd_enabled (PANEL_MENU_BUTTON (info->widget),
dnd_enabled);
......@@ -252,10 +250,7 @@ applet_remove_callback (GtkWidget *widget,
AppletInfo *info)
{
if (info->type == PANEL_OBJECT_DRAWER)
drawer_query_deletion (info->data);
else
panel_profile_delete_object (info);
panel_profile_delete_object (info);
}
static inline GdkScreen *
......@@ -285,21 +280,6 @@ applet_callback_callback (GtkWidget *widget,
else if (!strcmp (menu->name, "properties"))
launcher_properties (menu->info->data);
break;
case PANEL_OBJECT_DRAWER:
if (strcmp (menu->name, "add") == 0) {
Drawer *drawer = menu->info->data;
panel_addto_present (GTK_MENU_ITEM (widget),
panel_toplevel_get_panel_widget (drawer->toplevel));
} else if (strcmp (menu->name, "properties") == 0) {
Drawer *drawer = menu->info->data;
panel_properties_dialog_present (drawer->toplevel);
} else if (strcmp (menu->name, "help") == 0) {
panel_show_help (screen,
"user-guide", "gospanel-18", NULL);
}
break;
case PANEL_OBJECT_MENU:
panel_menu_button_invoke_menu (
PANEL_MENU_BUTTON (menu->info->widget), menu->name);
......@@ -526,7 +506,7 @@ panel_applet_create_bare_menu (AppletInfo *info)
return menu;
}
GtkWidget *
static GtkWidget *
panel_applet_get_menu (AppletInfo *info)
{
GtkWidget *menu;
......@@ -845,21 +825,6 @@ panel_applet_destroy (GtkWidget *widget,
queued_position_saves =
g_slist_remove (queued_position_saves, info);
if (info->type == PANEL_OBJECT_DRAWER) {
Drawer *drawer = info->data;
if (drawer->toplevel) {
PanelWidget *panel_widget;
panel_widget = panel_toplevel_get_panel_widget (
drawer->toplevel);
panel_widget->master_widget = NULL;
gtk_widget_destroy (GTK_WIDGET (drawer->toplevel));
drawer->toplevel = NULL;
}
}
if (info->type != PANEL_OBJECT_APPLET)
panel_lockdown_notify_remove (G_CALLBACK (panel_applet_recreate_menus),
info);
......@@ -1061,12 +1026,6 @@ panel_applet_load_idle_handler (gpointer dummy)
applet->position,
applet->id);
break;
case PANEL_OBJECT_DRAWER:
drawer_load_from_gconf (panel_widget,
applet->locked,
applet->position,
applet->id);
break;
case PANEL_OBJECT_MENU:
panel_menu_button_load_from_gconf (panel_widget,
applet->locked,
......@@ -1424,22 +1383,6 @@ panel_applet_register (GtkWidget *applet,
(GConfClientNotifyFunc) panel_applet_locked_change_notify,
G_OBJECT (applet));
if (type == PANEL_OBJECT_DRAWER) {
Drawer *drawer = data;
PanelWidget *assoc_panel;
assoc_panel = panel_toplevel_get_panel_widget (drawer->toplevel);
g_object_set_data (G_OBJECT (applet),
PANEL_APPLET_ASSOC_PANEL_KEY, assoc_panel);
assoc_panel->master_widget = applet;
g_object_add_weak_pointer (
G_OBJECT (applet), (gpointer *) &assoc_panel->master_widget);
}
g_object_set_data (G_OBJECT (applet),
PANEL_APPLET_FORBIDDEN_PANELS, NULL);
registered_applets = g_slist_append (registered_applets, info);
if (panel_widget_add (panel, applet, locked, pos, exactpos) == -1 &&
......
......@@ -98,7 +98,6 @@ gboolean panel_applet_can_freely_move (AppletInfo *applet);
/* True if the locked flag is writable */
gboolean panel_applet_lockable (AppletInfo *applet);
GtkWidget *panel_applet_get_menu (AppletInfo *info);
GtkWidget *panel_applet_get_edit_menu (AppletInfo *info);
void panel_applet_menu_set_recurse (GtkMenu *menu,
......
This diff is collapsed.
#ifndef DRAWER_H
#define DRAWER_H
#include "panel.h"
G_BEGIN_DECLS
#define PANEL_DRAWER_N_LISTENERS 3
typedef struct {
char *tooltip;
PanelToplevel *toplevel;
GtkWidget *button;
gboolean opened_for_drag;
guint close_timeout_id;
AppletInfo *info;
guint listeners [PANEL_DRAWER_N_LISTENERS];
} Drawer;
void panel_drawer_create (PanelToplevel *toplevel,
int position,
const char *custom_icon,
gboolean use_custom_icon,
const char *tooltip);
char *panel_drawer_create_with_id (const char *toplevel_id,
int position,
const char *custom_icon,
gboolean use_custom_icon,
const char *tooltip);
void panel_drawer_set_dnd_enabled (Drawer *drawer,
gboolean dnd_enabled);
void drawer_load_from_gconf (PanelWidget *panel_widget,
gboolean locked,
gint position,
const char *id);
void drawer_query_deletion (Drawer *drawer);
G_END_DECLS
#endif
......@@ -165,24 +165,6 @@ launcher_launch (Launcher *launcher,
}
}
g_free (type);
if (panel_global_config_get_drawer_auto_close ()) {
PanelToplevel *toplevel;
PanelToplevel *parent;
toplevel = PANEL_WIDGET (gtk_widget_get_parent (launcher->button))->toplevel;
if (panel_toplevel_get_is_attached (toplevel)) {
parent = panel_toplevel_get_attach_toplevel (toplevel);
while (panel_toplevel_get_is_attached (parent)) {
toplevel = parent;
parent = panel_toplevel_get_attach_toplevel (toplevel);
}
panel_toplevel_hide (toplevel, FALSE, -1);
}
}
}
static void
......
......@@ -112,11 +112,6 @@ main (int argc, char **argv)
panel_lockdown_init ();
panel_profile_load ();
/*add forbidden lists to ALL panels*/
g_slist_foreach (panels,
(GFunc)panel_widget_add_forbidden,
NULL);
xstuff_init ();
/* Flush to make sure our struts are seen by everyone starting
......
......@@ -37,7 +37,6 @@
#include "launcher.h"
#include "panel-util.h"
#include "panel.h"
#include "drawer.h"
#include "panel-config-global.h"
#include "panel-stock-icons.h"
#include "panel-action-button.h"
......
......@@ -549,15 +549,6 @@ panel_action_button_clicked (GtkButton *gtk_button)
g_return_if_fail (button->priv->type > PANEL_ACTION_NONE);
g_return_if_fail (button->priv->type < PANEL_ACTION_LAST);
if (panel_global_config_get_drawer_auto_close ()) {
PanelToplevel *toplevel;
toplevel = PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (button)))->toplevel;
if (panel_toplevel_get_is_attached (toplevel))
panel_toplevel_hide (toplevel, FALSE, -1);
}
if (actions [button->priv->type].invoke)
actions [button->priv->type].invoke (GTK_WIDGET (button));
}
......
......@@ -34,7 +34,6 @@
#include "launcher.h"
#include "panel.h"
#include "drawer.h"
#include "panel-applets-manager.h"
#include "panel-applet-frame.h"
#include "panel-action-button.h"
......@@ -87,8 +86,7 @@ typedef enum {
PANEL_ADDTO_LAUNCHER_NEW,
PANEL_ADDTO_MENU,
PANEL_ADDTO_MENUBAR,
PANEL_ADDTO_SEPARATOR,
PANEL_ADDTO_DRAWER
PANEL_ADDTO_SEPARATOR
} PanelAddtoItemType;
typedef struct {
......@@ -168,17 +166,6 @@ static PanelAddtoItemInfo internal_addto_items [] = {
NULL,
NULL,
"SEPARATOR:NEW",
TRUE },
{ PANEL_ADDTO_DRAWER,
N_("Drawer"),
N_("A pop out drawer to store other items in"),
PANEL_ICON_DRAWER,
PANEL_ACTION_NONE,
NULL,
NULL,
NULL,
"DRAWER:NEW",
TRUE }
};
......@@ -805,11 +792,6 @@ panel_addto_add_item (PanelAddtoDialog *dialog,
panel_separator_create (dialog->panel_widget->toplevel,
dialog->insertion_position);
break;
case PANEL_ADDTO_DRAWER:
panel_drawer_create (dialog->panel_widget->toplevel,
dialog->insertion_position,
NULL, FALSE, NULL);
break;
}
}
......@@ -1035,7 +1017,6 @@ static void
panel_addto_name_change (PanelAddtoDialog *dialog,
const char *name)
{
char *title;
char *label;
label = NULL;
......@@ -1044,18 +1025,11 @@ panel_addto_name_change (PanelAddtoDialog *dialog,
label = g_strdup_printf (_("Find an _item to add to \"%s\":"),
name);
if (panel_toplevel_get_is_attached (dialog->panel_widget->toplevel)) {
title = g_strdup_printf (_("Add to Drawer"));
if (label == NULL)
label = g_strdup (_("Find an _item to add to the drawer:"));
} else {
title = g_strdup_printf (_("Add to Panel"));
if (label == NULL)
label = g_strdup (_("Find an _item to add to the panel:"));
}
if (label == NULL)
label = g_strdup (_("Find an _item to add to the panel:"));
gtk_window_set_title (GTK_WINDOW (dialog->addto_dialog), title);
g_free (title);
gtk_window_set_title (GTK_WINDOW (dialog->addto_dialog),
_("Add to Panel"));
gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->label), label);
g_free (label);
......
......@@ -43,33 +43,6 @@ typedef enum {
PANEL_ORIENT_RIGHT,
} PanelOrient;
static GConfEnumStringPair panel_orient_map [] = {
{ PANEL_ORIENT_UP, "panel-orient-up" },
{ PANEL_ORIENT_DOWN, "panel-orient-down" },
{ PANEL_ORIENT_LEFT, "panel-orient-left" },
{ PANEL_ORIENT_RIGHT, "panel-orient-right" },
{ 0, NULL }
};
static gboolean
panel_compatibility_map_orient_string (const char *str,
PanelOrient *orient)
{
int mapped;
g_return_val_if_fail (orient != NULL, FALSE);
if (!str)
return FALSE;
if (!gconf_string_to_enum (panel_orient_map, str, &mapped))
return FALSE;
*orient = mapped;
return TRUE;
}
static GConfEnumStringPair panel_orientation_map [] = {
{ GTK_ORIENTATION_HORIZONTAL, "panel-orientation-horizontal" },
{ GTK_ORIENTATION_VERTICAL, "panel-orientation-vertical" },
......@@ -132,7 +105,6 @@ panel_compatibility_map_edge_string (const char *str,
typedef enum {
EDGE_PANEL,
DRAWER_PANEL,
ALIGNED_PANEL,
SLIDING_PANEL,
FLOATING_PANEL,
......@@ -141,7 +113,6 @@ typedef enum {
static GConfEnumStringPair panel_type_map [] = {
{ EDGE_PANEL, "edge-panel" },
{ DRAWER_PANEL, "drawer-panel" },
{ ALIGNED_PANEL, "aligned-panel" },
{ SLIDING_PANEL, "sliding-panel" },
{ FLOATING_PANEL, "floating-panel" },
......@@ -376,53 +347,6 @@ panel_compatibility_migrate_edge_panel_settings (GConfClient *client,
panel_compatibility_migrate_edge_setting (client, toplevel_dir, panel_dir);
}
static void
panel_compatibility_migrate_drawer_panel_settings (GConfClient *client,
const char *toplevel_dir,
const char *panel_dir)
{
PanelOrient orient;
const char *key;
char *orient_str;
key = panel_gconf_sprintf ("%s/expand", toplevel_dir);
gconf_client_set_bool (client, key, FALSE, NULL);
key = panel_gconf_sprintf ("%s/panel_orient", panel_dir);
orient_str = gconf_client_get_string (client, key, NULL);
if (panel_compatibility_map_orient_string (orient_str, &orient)) {
PanelOrientation orientation;
switch (orient) {
case PANEL_ORIENT_DOWN:
orientation = PANEL_ORIENTATION_TOP;
break;
case PANEL_ORIENT_UP:
orientation = PANEL_ORIENTATION_BOTTOM;
break;
case PANEL_ORIENT_RIGHT:
orientation = PANEL_ORIENTATION_LEFT;
break;
case PANEL_ORIENT_LEFT:
orientation = PANEL_ORIENTATION_RIGHT;
break;
default:
orientation = 0;
g_assert_not_reached ();
break;
}
key = panel_gconf_sprintf ("%s/orientation", toplevel_dir);
gconf_client_set_string (client,
key,
panel_profile_map_orientation (orientation),
NULL);
}
g_free (orient_str);
}
static void
panel_compatibility_migrate_corner_panel_settings (GConfClient *client,
const char *toplevel_dir,
......@@ -549,8 +473,7 @@ panel_compatibility_migrate_menu_panel_settings (GConfClient *client,
static void
panel_compatibility_migrate_panel_type (GConfClient *client,
const char *toplevel_dir,
const char *panel_dir,
gboolean *is_drawer)
const char *panel_dir)
{
PanelType type;
const char *key;
......@@ -570,10 +493,6 @@ panel_compatibility_migrate_panel_type (GConfClient *client,
case EDGE_PANEL:
panel_compatibility_migrate_edge_panel_settings (client, toplevel_dir, panel_dir);
break;
case DRAWER_PANEL:
panel_compatibility_migrate_drawer_panel_settings (client, toplevel_dir, panel_dir);
*is_drawer = TRUE;
break;
case ALIGNED_PANEL:
panel_compatibility_migrate_corner_panel_settings (client, toplevel_dir, panel_dir);
break;
......@@ -595,8 +514,7 @@ panel_compatibility_migrate_panel_type (GConfClient *client,
static char *
panel_compatibility_migrate_panel_settings (GConfClient *client,
GSList *toplevel_id_list,
const char *panel_id,
gboolean *is_drawer)
const char *panel_id)
{
const char *key;
char *toplevel_id;
......@@ -665,7 +583,7 @@ panel_compatibility_migrate_panel_settings (GConfClient *client,
gconf_client_set_bool (client, key, auto_hide, NULL);
/* migrate different panel types to toplevels */
panel_compatibility_migrate_panel_type (client, toplevel_dir, panel_dir, is_drawer);
panel_compatibility_migrate_panel_type (client, toplevel_dir, panel_dir);
/* background settings */
panel_compatibility_migrate_background_settings (client, toplevel_dir, panel_dir);
......@@ -703,54 +621,6 @@ panel_compatibility_migrate_panel_id (GConfClient *client,
return retval;
}
static void
panel_compatibility_migrate_drawer_settings (GConfClient *client,
PanelGConfKeyType key_type,
const char *object_id,
GHashTable *panel_id_hash)
{
const char *key;
char *toplevel_id;
char *panel_id;
char *custom_icon;
char *pixmap;
/* unique-drawer-panel-id -> attached_toplevel_id */
key = panel_gconf_full_key (key_type, object_id, "attached_toplevel_id");
toplevel_id = gconf_client_get_string (client, key, NULL);
key = panel_gconf_full_key (key_type, object_id, "unique-drawer-panel-id");
panel_id = gconf_client_get_string (client, key, NULL);
if (!toplevel_id && panel_id &&
(toplevel_id = g_hash_table_lookup (panel_id_hash, panel_id))) {
key = panel_gconf_full_key (key_type, object_id, "attached_toplevel_id");
gconf_client_set_string (client, key, toplevel_id, NULL);
toplevel_id = NULL;
}
/* pixmap -> custom_icon */
key = panel_gconf_full_key (key_type, object_id, "custom_icon");
custom_icon = gconf_client_get_string (client, key, NULL);
key = panel_gconf_full_key (key_type, object_id, "pixmap");
pixmap = gconf_client_get_string (client, key, NULL);
if (!custom_icon && pixmap) {
key = panel_gconf_full_key (key_type, object_id, "custom_icon");
gconf_client_set_string (client, key, pixmap, NULL);
key = panel_gconf_full_key (key_type, object_id, "use_custom_icon");
gconf_client_set_bool (client, key, TRUE, NULL);
}
g_free (toplevel_id);
g_free (panel_id);
g_free (custom_icon);
g_free (pixmap);
}
static void
panel_compatibility_migrate_menu_button_settings (GConfClient *client,
PanelGConfKeyType key_type,
......@@ -824,10 +694,6 @@ panel_compatibility_migrate_objects (GConfClient *client,
if (panel_profile_map_object_type_string (object_type_str, &object_type)) {
switch (object_type) {
case PANEL_OBJECT_DRAWER:
panel_compatibility_migrate_drawer_settings (
client, key_type, id, panel_id_hash);
break;
case PANEL_OBJECT_MENU:
panel_compatibility_migrate_menu_button_settings (
client, key_type, id);
......@@ -937,16 +803,12 @@ panel_compatibility_migrate_panel_id_list (GConfClient *client)
for (l = panel_id_list; l; l = l->next) {
char *new_id;
gboolean is_drawer = FALSE;
new_id = panel_compatibility_migrate_panel_settings (client,
toplevel_id_list,
l->data,
&is_drawer);
l->data);
/* Drawer toplevels don't belong on the toplevel list */
if (!is_drawer)
toplevel_id_list = g_slist_prepend (toplevel_id_list, new_id);
toplevel_id_list = g_slist_prepend (toplevel_id_list, new_id);
g_hash_table_insert (panel_id_hash, l->data, new_id);
}
......
......@@ -36,7 +36,6 @@
typedef struct {
guint tooltips_enabled : 1;
guint enable_animations : 1;
guint drawer_auto_close : 1;
guint confirm_panel_remove : 1;
guint highlight_when_over : 1;
} GlobalConfig;
......@@ -60,14 +59,6 @@ panel_global_config_get_enable_animations (void)
return global_config.enable_animations;
}
gboolean
panel_global_config_get_drawer_auto_close (void)
{
g_assert (global_config_initialised == TRUE);
return global_config.drawer_auto_close;
}
gboolean
panel_global_config_get_tooltips_enabled (void)
{
......@@ -106,10 +97,6 @@ panel_global_config_set_entry (GConfEntry *entry)
global_config.enable_animations =
gconf_value_get_bool (value);
else if (strcmp (key, "drawer_autoclose") == 0)
global_config.drawer_auto_close =
gconf_value_get_bool (value);
else if (strcmp (key, "confirm_panel_remove") == 0)
global_config.confirm_panel_remove =
gconf_value_get_bool (value);
......
......@@ -34,7 +34,6 @@ void panel_global_config_load (void);
gboolean panel_global_config_get_highlight_when_over (void);
gboolean panel_global_config_get_enable_animations (void);
gboolean panel_global_config_get_drawer_auto_close (void);
gboolean panel_global_config_get_tooltips_enabled (void);
gboolean panel_global_config_get_confirm_panel_remove (void);
......
......@@ -41,7 +41,6 @@
#include "panel-util.h"
#include "panel.h"
#include "menu.h"
#include "applet.h"
#include "panel-config-global.h"
#include "panel-profile.h"
#include "panel-properties-dialog.h"
......@@ -58,7 +57,7 @@ panel_context_menu_create_new_panel (GtkWidget *menuitem)
static void
panel_context_menu_delete_panel (PanelToplevel *toplevel)
{
if (panel_toplevel_is_last_unattached (toplevel)) {
if (panel_toplevel_is_last (toplevel)) {
panel_error_dialog (GTK_WINDOW (toplevel),
gtk_window_get_screen (GTK_WINDOW (toplevel)),
"cannot_delete_last_panel", TRUE,
...