Commit 1e4a5c8d authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin

cleanup and use a GtkSeparator menu item as a separator.

2002-03-25  Mark McLoughlin  <mark@skynet.ie>

        * applet.c: (panel_applet_create_menu): cleanup and use
        a GtkSeparator menu item as a separator.

        * basep-widget.c: kill uneeded panel_applet_in_drag def.

        * foobar-widget.c: (append_actions_menu): use 'Run Program...' instead
        of 'Run...' as suggested by calum.

        * main.c: (main): add a notify to /desktop/gnome/interface instead of
        /desktop/gnome/menus.

        * menu.c:
        (panel_menu_have_icons): kill old crack and use the correct key.
        (menus_have_icons_changed), (panel_menu_new): use the correct key
        for menus_have_icons.
        (image_menuitem_size_request): impl hack to make sure menu items
        without images are the same height as ones with images.
        (setup_full_menuitem): hook up to size_request.
        (create_root_menu): use 'Run Program...' instead of 'Run..'

        * menu.h: kill panel_menu_have_icons and bogus key definition.

        * panel-widget.[ch]:
        (panel_widget_get_free_space), (panel_widget_move): kill unused.
        (panel_widget_switch_applet_right): return is we're at the end of
        the panel.
        (panel_widget_switch_applet_left): return is we've hit the start of
        the panel.
        (panel_widget_switch_move_applet): only switch applets when we actual
        hit an applet.
parent 00359c32
2002-03-25 Mark McLoughlin <mark@skynet.ie>
* applet.c: (panel_applet_create_menu): cleanup and use
a GtkSeparator menu item as a separator.
* basep-widget.c: kill uneeded panel_applet_in_drag def.
* foobar-widget.c: (append_actions_menu): use 'Run Program...' instead
of 'Run...' as suggested by calum.
* main.c: (main): add a notify to /desktop/gnome/interface instead of
/desktop/gnome/menus.
* menu.c:
(panel_menu_have_icons): kill old crack and use the correct key.
(menus_have_icons_changed), (panel_menu_new): use the correct key
for menus_have_icons.
(image_menuitem_size_request): impl hack to make sure menu items
without images are the same height as ones with images.
(setup_full_menuitem): hook up to size_request.
(create_root_menu): use 'Run Program...' instead of 'Run..'
* menu.h: kill panel_menu_have_icons and bogus key definition.
* panel-widget.[ch]:
(panel_widget_get_free_space), (panel_widget_move): kill unused.
(panel_widget_switch_applet_right): return is we're at the end of
the panel.
(panel_widget_switch_applet_left): return is we've hit the start of
the panel.
(panel_widget_switch_move_applet): only switch applets when we actual
hit an applet.
2002-03-22 Mark McLoughlin <mark@skynet.ie>
* applet.c: (panel_applet_clean): kill the applet
......
......@@ -528,12 +528,18 @@ add_to_submenus (AppletInfo *info,
static GtkWidget *
panel_applet_create_menu (AppletInfo *info)
{
GtkWidget *retval;
GtkWidget *menu;
GtkWidget *menuitem;
GList *l;
retval = g_object_ref (panel_menu_new ());
gtk_object_sink (GTK_OBJECT (retval));
menu = g_object_ref (panel_menu_new ());
gtk_object_sink (GTK_OBJECT (menu));
/* connect the deactivate signal, so that we can "re-allow"
* autohide when the menu is deactivated.
*/
g_signal_connect (menu, "deactivate",
G_CALLBACK (applet_menu_deactivate), info);
if (!commie_mode) {
GtkWidget *image;
......@@ -548,46 +554,35 @@ panel_applet_create_menu (AppletInfo *info)
g_signal_connect (menuitem, "activate",
G_CALLBACK (applet_remove_callback), info);
gtk_menu_shell_append (GTK_MENU_SHELL (retval), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_image_menu_item_new ();
/*
* FIXME: should have a "Move" pixmap.
/* FIXME: should have a "Move" pixmap.
*/
setup_menuitem (menuitem, NULL, _("Move"));
g_signal_connect (menuitem, "activate",
G_CALLBACK (move_applet_callback), info);
gtk_menu_shell_append (GTK_MENU_SHELL (retval), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
}
if (info->user_menu) {
menuitem = gtk_image_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (retval), menuitem);
if (!info->user_menu)
return menu;
gtk_widget_set_sensitive (menuitem, FALSE);
gtk_widget_show (menuitem);
}
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
for (l = info->user_menu; l; l = l->next) {
AppletUserMenu *menu = (AppletUserMenu *)l->data;
AppletUserMenu *user_menu = (AppletUserMenu *)l->data;
add_to_submenus (info, "", menu->name, menu,
retval, info->user_menu);
add_to_submenus (info, "", user_menu->name, user_menu,
menu, info->user_menu);
}
/*
* connect the deactivate signal, so that we can "re-allow"
* autohide when the menu is deactivated.
*/
g_signal_connect (retval, "deactivate",
G_CALLBACK (applet_menu_deactivate), info);
return retval;
return menu;
}
static void
......
......@@ -31,7 +31,6 @@
#undef BASEP_WIDGET_DEBUG
extern gboolean panel_applet_in_drag;
extern GSList *panel_list;
extern int panels_to_sync;
......
......@@ -211,7 +211,7 @@ append_actions_menu (GtkWidget *menu_bar)
menu = panel_menu_new ();
item = pixmap_menu_item_new (_("Run..."), "gnome-run.png",
item = pixmap_menu_item_new (_("Run Program..."), "gnome-run.png",
FALSE /* force_image */);
gtk_tooltips_set_tip (panel_tooltips, item,
_("Run applications, if you know the "
......
......@@ -212,7 +212,7 @@ main(int argc, char **argv)
multiscreen_init ();
panel_gconf_add_dir ("/apps/panel/global");
panel_gconf_add_dir ("/desktop/gnome/menus");
panel_gconf_add_dir ("/desktop/gnome/interface");
panel_gconf_notify_add ("/apps/panel/global", panel_global_config_notify, NULL);
status_applet_create_offscreen ();
......
......@@ -141,55 +141,14 @@ static void setup_menuitem_try_pixmap (GtkWidget *menuitem,
const char *try_file,
const char *title);
static gboolean panel_menus_have_icons = TRUE;
static void
panel_menu_have_icons_notify (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
gpointer user_data)
{
GConfValue *value = gconf_entry_get_value (entry);
if (value->type == GCONF_VALUE_BOOL)
panel_menus_have_icons = gconf_value_get_bool (value);
else
/* default to true */
panel_menus_have_icons = TRUE;
}
gboolean
static inline gboolean
panel_menu_have_icons (void)
{
static guint notify_id = 0;
if (notify_id == 0) {
GConfValue *value;
GConfClient *client = panel_gconf_get_client ();
gchar *key = PANEL_MENU_HAVE_ICONS_KEY;
GError *error = NULL;
notify_id = gconf_client_notify_add (client, key,
panel_menu_have_icons_notify,
NULL, NULL, &error);
if (error) {
g_warning (G_STRLOC ": failed to add notification for '%s' : '%s'",
key, error->message);
g_error_free (error);
}
value = gconf_client_get (client, key, NULL);
if (value != NULL &&
value->type == GCONF_VALUE_BOOL)
panel_menus_have_icons = gconf_value_get_bool (value);
else
/* default to true */
panel_menus_have_icons = TRUE;
if (value != NULL)
gconf_value_free (value);
}
return panel_menus_have_icons;
return gconf_client_get_bool (
panel_gconf_get_client (),
"/desktop/gnome/interface/menus_have_icons",
NULL);
}
/*to be called on startup to load in some of the directories,
......@@ -424,55 +383,49 @@ setup_menu_panel (GtkWidget *menu)
}
static void
pixmaps_changed (GConfClient* client,
guint cnxn_id,
GConfEntry *entry,
gpointer user_data)
menus_have_icons_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
GtkWidget *menu)
{
GtkWidget *menu = user_data;
GConfValue *value = gconf_entry_get_value (entry);
GList *list, *li;
gboolean pixmaps;
GConfValue *value;
GList *list, *l;
gboolean have_icons = TRUE;
value = gconf_entry_get_value (entry);
if (value->type == GCONF_VALUE_BOOL)
pixmaps = gconf_value_get_bool (value);
else
/* default to true */
pixmaps = TRUE;
have_icons = gconf_value_get_bool (value);
list = g_list_copy (GTK_MENU_SHELL (menu)->children);
for (li = list;
li != NULL;
li = li->next) {
GtkWidget *item = li->data;
for (l = list; l; l = l->next) {
GtkWidget *item = l->data;
GtkWidget *cur_image;
GtkWidget *image;
if ( ! GTK_IS_IMAGE_MENU_ITEM (item))
if (!GTK_IS_IMAGE_MENU_ITEM (item))
continue;
image = g_object_get_data (G_OBJECT (item), "Panel:Image");
if (image == NULL)
if (!image)
continue;
/* A forced image is always on */
if (g_object_get_data (G_OBJECT (item),
"Panel:ForceImage"))
if (g_object_get_data (G_OBJECT (item), "Panel:ForceImage"))
continue;
cur_image = gtk_image_menu_item_get_image
(GTK_IMAGE_MENU_ITEM (item));
cur_image = gtk_image_menu_item_get_image (
GTK_IMAGE_MENU_ITEM (item));
if (pixmaps) {
if (have_icons) {
if (cur_image != image) {
gtk_image_menu_item_set_image
(GTK_IMAGE_MENU_ITEM (item), image);
gtk_image_menu_item_set_image (
GTK_IMAGE_MENU_ITEM (item), image);
gtk_widget_show (image);
}
} else {
gtk_image_menu_item_set_image
(GTK_IMAGE_MENU_ITEM (item), NULL);
gtk_image_menu_item_set_image (
GTK_IMAGE_MENU_ITEM (item), NULL);
}
}
g_list_free (list);
......@@ -697,12 +650,17 @@ GtkWidget *
panel_menu_new (void)
{
GtkWidget *menu;
menu = gtk_menu_new ();
panel_gconf_notify_add_while_alive (PANEL_MENU_HAVE_ICONS_KEY,
pixmaps_changed,
panel_gconf_notify_add_while_alive ("/desktop/gnome/interface/menus_have_icons",
(GConfClientNotifyFunc) menus_have_icons_changed,
G_OBJECT (menu));
g_signal_connect_after (G_OBJECT (menu), "show",
G_CALLBACK (panel_make_sure_menu_within_screen), NULL);
g_signal_connect_after (menu, "show",
G_CALLBACK (panel_make_sure_menu_within_screen),
NULL);
return menu;
}
......@@ -1552,6 +1510,18 @@ drag_data_get_string_cb (GtkWidget *widget, GdkDragContext *context,
strlen(string));
}
static void
image_menuitem_size_request (GtkWidget *menuitem,
GtkRequisition *requisition,
gpointer dummy)
{
/* If we don't have a pixmap for this menuitem
* at least make sure its the same height as
* the rest.
*/
requisition->height = MAX (requisition->height, ICON_SIZE);
}
static void
setup_full_menuitem (GtkWidget *menuitem, GtkWidget *pixmap,
const char *title, const char *item_loc,
......@@ -1570,7 +1540,7 @@ setup_full_menuitem (GtkWidget *menuitem, GtkWidget *pixmap,
gtk_container_add (GTK_CONTAINER (menuitem), label);
if (pixmap != NULL) {
if (pixmap) {
g_object_set_data_full (G_OBJECT (menuitem),
"Panel:Image",
g_object_ref (G_OBJECT (pixmap)),
......@@ -1579,7 +1549,10 @@ setup_full_menuitem (GtkWidget *menuitem, GtkWidget *pixmap,
if (panel_menu_have_icons ())
gtk_image_menu_item_set_image
(GTK_IMAGE_MENU_ITEM (menuitem), pixmap);
}
} else
g_signal_connect (menuitem, "size_request",
G_CALLBACK (image_menuitem_size_request),
NULL);
if (item_loc != NULL) {
ShowItemMenu *sim = g_new0 (ShowItemMenu, 1);
......@@ -3592,7 +3565,7 @@ create_root_menu (GtkWidget *root_menu,
if ( ! no_run_box && run_item) {
menuitem = gtk_image_menu_item_new ();
setup_menuitem_try_pixmap (menuitem, "gnome-run.png",
_("Run..."));
_("Run Program..."));
g_signal_connect (G_OBJECT (menuitem), "activate",
G_CALLBACK (run_cb), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (root_menu), menuitem);
......
......@@ -121,9 +121,6 @@ enum {
HIDEBUTTONS_NONE
};
#define PANEL_MENU_HAVE_ICONS_KEY "/desktop/gnome/menus/show-icons"
gboolean panel_menu_have_icons (void);
GtkWidget * panel_menu_new (void);
void panel_load_menu_image_deferred (GtkWidget *image_menu_item,
const char *image_filename,
......
......@@ -725,62 +725,69 @@ panel_widget_queue_applet_for_resize(AppletData *ad)
static void
panel_widget_switch_applet_right(PanelWidget *panel, GList *list)
panel_widget_switch_applet_right (PanelWidget *panel,
GList *list)
{
AppletData *ad;
AppletData *nad = NULL;
g_return_if_fail(PANEL_IS_WIDGET(panel));
g_return_if_fail(list!=NULL);
g_return_if_fail (PANEL_IS_WIDGET (panel));
g_return_if_fail (list != NULL);
ad = list->data;
if(list->next)
if (ad->pos + ad->min_cells >= panel->size)
return;
if (list->next)
nad = list->next->data;
if(!nad || nad->pos > ad->pos+ad->min_cells) {
ad->pos++;
panel_widget_queue_applet_for_resize(ad);
if (!nad || nad->pos > ad->pos + ad->min_cells) {
ad->pos += MOVE_INCREMENT;
panel_widget_queue_applet_for_resize (ad);
return;
}
nad->pos = ad->pos;
ad->pos = nad->pos+nad->min_cells;
panel->applet_list = panel_g_list_swap_next(panel->applet_list,list);
ad->pos = nad->pos + nad->min_cells;
panel->applet_list = panel_g_list_swap_next (panel->applet_list,list);
panel_widget_queue_applet_for_resize(ad);
panel_widget_queue_applet_for_resize(nad);
panel_widget_queue_applet_for_resize (ad);
panel_widget_queue_applet_for_resize (nad);
}
static void
panel_widget_switch_applet_left(PanelWidget *panel, GList *list)
panel_widget_switch_applet_left (PanelWidget *panel,
GList *list)
{
AppletData *ad;
AppletData *pad = NULL;
g_return_if_fail(PANEL_IS_WIDGET(panel));
g_return_if_fail(list!=NULL);
g_return_if_fail (PANEL_IS_WIDGET (panel));
g_return_if_fail (list != NULL);
ad = list->data;
if (ad->pos <= 0)
return;
if(list->prev)
if (list->prev)
pad = list->prev->data;
if(!pad || pad->pos+pad->min_cells < ad->pos) {
ad->pos--;
panel_widget_queue_applet_for_resize(ad);
if (pad && pad->pos+pad->cells >= ad->pos)
panel_widget_queue_applet_for_resize(pad);
if (!pad || pad->pos + pad->min_cells < ad->pos) {
ad->pos -= MOVE_INCREMENT;
panel_widget_queue_applet_for_resize (ad);
if (pad && (pad->pos + pad->cells) >= ad->pos)
panel_widget_queue_applet_for_resize (pad);
return;
}
ad->pos = pad->pos;
pad->pos = ad->pos+ad->min_cells;
panel->applet_list = panel_g_list_swap_prev(panel->applet_list,list);
pad->pos = ad->pos + ad->min_cells;
panel->applet_list = panel_g_list_swap_prev (panel->applet_list, list);
panel_widget_queue_applet_for_resize(ad);
panel_widget_queue_applet_for_resize(pad);
panel_widget_queue_applet_for_resize (ad);
panel_widget_queue_applet_for_resize (pad);
}
static int
......@@ -1952,49 +1959,6 @@ panel_widget_get_cursorloc (PanelWidget *panel)
}
}
#ifdef FIXME /* This isn't used anymore but looks useful */
/*get amount of free space around the applet (including the applet size),
or return 0 on error or if the panel is packed*/
int
panel_widget_get_free_space(PanelWidget *panel, GtkWidget *applet)
{
int right,left;
GList *li;
AppletData *ad;
g_return_val_if_fail(PANEL_IS_WIDGET(panel), 0);
g_return_val_if_fail(GTK_IS_WIDGET(applet), 0);
/*this function doesn't make sense on packed panels*/
if(panel->packed)
return 0;
right = panel->size;
left = 0;
for(li = panel->applet_list; li; li = g_list_next(li)) {
ad = li->data;
if(ad->applet == applet)
break;
}
/*the applet is not on this panel*/
if(!li)
return 0;
if(li->prev) {
AppletData *pad = li->prev->data;
left = pad->pos+pad->cells;
}
if(li->next) {
AppletData *nad = li->next->data;
right = nad->pos;
}
return right - left;
}
#endif
/*calculates the value to move the applet by*/
static int
panel_widget_get_moveby (PanelWidget *panel, int pos, int offset)
......@@ -2662,46 +2626,6 @@ panel_widget_reparent (PanelWidget *old_panel,
return pos;
}
#ifdef FIXME /* This isn't used anymore but looks useful */
int
panel_widget_move (PanelWidget *panel, GtkWidget *applet, int pos)
{
AppletData *ad;
g_return_val_if_fail(PANEL_IS_WIDGET(panel),-1);
g_return_val_if_fail(GTK_IS_WIDGET(applet),-1);
g_return_val_if_fail(pos>=0,-1);
ad = g_object_get_data (G_OBJECT (applet), PANEL_APPLET_DATA);
ad->pos = -1;
panel->applet_list = g_list_remove (panel->applet_list, ad);
if(pos < 0)
pos = 0;
if(get_applet_list_pos(panel,pos))
/*this is a slight hack so that this applet is
inserted AFTER an applet with this pos number*/
pos++;
if(pos==-1) return -1;
ad->pos = pos;
/*reset size to 1*/
ad->cells = 1;
ad->min_cells = 1;
panel->applet_list =
g_list_insert_sorted(panel->applet_list,ad,
(GCompareFunc)applet_data_compare);
g_signal_emit (G_OBJECT(panel),
panel_widget_signals[APPLET_MOVE_SIGNAL],
0, ad->applet);
gtk_widget_queue_resize(GTK_WIDGET(panel));
return pos;
}
#endif
void
panel_widget_change_params(PanelWidget *panel,
GtkOrientation orient,
......@@ -2797,60 +2721,53 @@ static void
panel_widget_push_move_applet (PanelWidget *panel,
GtkDirectionType dir)
{
AppletData *ad;
gint increment = MOVE_INCREMENT;
AppletData *applet;
int increment = 0;
ad = panel->currently_dragged_applet;
g_return_if_fail (ad);
applet = panel->currently_dragged_applet;
g_return_if_fail (applet);
switch (dir) {
case GTK_DIR_LEFT:
case GTK_DIR_UP:
increment = -increment;
increment = -MOVE_INCREMENT;
break;
case GTK_DIR_RIGHT:
case GTK_DIR_DOWN:
increment = MOVE_INCREMENT;
break;
default:
return;
}
panel_widget_push_move (panel, ad, increment);
panel_widget_push_move (panel, applet, increment);
}
static void
panel_widget_switch_move_applet (PanelWidget *panel,
GtkDirectionType dir)
{
AppletData *ad;
AppletData *nad = NULL;
GList *list;
gint increment;
AppletData *applet;
GList *list;
ad = panel->currently_dragged_applet;
applet = panel->currently_dragged_applet;
g_return_if_fail (applet != NULL);
g_return_if_fail (ad);
list = g_list_find (panel->applet_list, applet);
g_return_if_fail (list != NULL);
list = g_list_find (panel->applet_list, ad);
g_return_if_fail (list);
switch (dir) {
case GTK_DIR_LEFT:
case GTK_DIR_UP:
if (list->prev)
nad = list->prev->data;
panel_widget_switch_applet_left (panel, list);
break;
case GTK_DIR_RIGHT:
case GTK_DIR_DOWN:
if (list->next)
nad = list->next->data;
panel_widget_switch_applet_right (panel, list);
break;
default:
return;
}
if (nad) {
increment = nad->pos - ad->pos;
panel_widget_switch_move (panel, ad, increment);
}
}
static void
......@@ -2876,6 +2793,7 @@ panel_widget_free_move_applet (PanelWidget *panel,
default:
return;
}
pos = panel_widget_get_free_spot (panel, ad,
increment + ad->pos + ad->drag_off);
panel_widget_nice_move (panel, ad, pos);
......
......@@ -165,22 +165,12 @@ void panel_widget_set_new_id (PanelWidget *panel);
/*needs to be called for drawers after add*/
void panel_widget_add_forbidden (PanelWidget *panel);
/*move applet to newpos*/
int panel_widget_move (PanelWidget *panel,
GtkWidget *applet,
int pos);
/*move applet to a different panel*/
int panel_widget_reparent (PanelWidget *old_panel,
PanelWidget *new_panel,
GtkWidget *applet,
int pos);
/*get amount of free space around the applet (including the applet size),
or return 0 on error or if the panel is packed*/
int panel_widget_get_free_space (PanelWidget *panel,
GtkWidget *applet);
/* use these for drag_off for special cases */
#define PW_DRAG_OFF_CURSOR -1
#define PW_DRAG_OFF_CENTER -2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment