Commit a7cd5bce authored by Vincent Untz's avatar Vincent Untz Committed by Vincent Untz
Browse files

Add separator internal applet. Based on patch by Carlos Garcia Campos

2006-01-13  Vincent Untz  <vuntz@gnome.org>

	Add separator internal applet. Based on patch by Carlos Garcia Campos
	<carlosg@gnome.org>. Fix bug #300593

	* Makefile.am: add new files
	* applet.c: (panel_applet_set_dnd_enabled): handle the separator case
	(applet_callback_callback): ditto
	(panel_applet_load_idle_handler): ditto
	* panel-addto.c: add separator item
	(panel_addto_add_item): handle separator case
	* panel-enums.h: add separator to the list of internal objects
	* panel-profile.c: add separator to the object map list
	* panel-separator.[ch]: new
	* panel.c: (orientation_change): handle separator case,
	(back_change): ditto
	(drop_internal_applet): ditto
parent fae248ee
2006-01-13 Vincent Untz <vuntz@gnome.org>
Add separator internal applet. Based on patch by Carlos Garcia Campos
<carlosg@gnome.org>. Fix bug #300593
* Makefile.am: add new files
* applet.c: (panel_applet_set_dnd_enabled): handle the separator case
(applet_callback_callback): ditto
(panel_applet_load_idle_handler): ditto
* panel-addto.c: add separator item
(panel_addto_add_item): handle separator case
* panel-enums.h: add separator to the list of internal objects
* panel-profile.c: add separator to the object map list
* panel-separator.[ch]: new
* panel.c: (orientation_change): handle separator case,
(back_change): ditto
(drop_internal_applet): ditto
2006-01-11 Sebastien Bacher <seb128@debian.org>
 
* panel-menu-items.c: (panel_place_menu_item_create_menu):
......
......@@ -100,6 +100,7 @@ panel_sources = \
panel-menu-bar.c \
panel-menu-button.c \
panel-menu-items.c \
panel-separator.c \
panel-recent.c \
panel-action-protocol.c \
panel-toplevel.c \
......@@ -144,6 +145,7 @@ panel_headers = \
panel-menu-bar.h \
panel-menu-button.h \
panel-menu-items.h \
panel-separator.h \
panel-recent.h \
panel-action-protocol.h \
panel-toplevel.h \
......
......@@ -24,6 +24,7 @@
#include "panel-applet-frame.h"
#include "panel-action-button.h"
#include "panel-menu-bar.h"
#include "panel-separator.h"
#include "panel-compatibility.h"
#include "panel-toplevel.h"
#include "panel-util.h"
......@@ -64,6 +65,7 @@ panel_applet_set_dnd_enabled (AppletInfo *info,
dnd_enabled);
break;
case PANEL_OBJECT_MENU_BAR:
case PANEL_OBJECT_SEPARATOR:
break;
default:
g_assert_not_reached ();
......@@ -269,6 +271,8 @@ applet_callback_callback (GtkWidget *widget,
* Applet's menu's are handled differently
*/
break;
case PANEL_OBJECT_SEPARATOR:
break;
default:
g_assert_not_reached ();
break;
......@@ -896,6 +900,11 @@ panel_applet_load_idle_handler (gpointer dummy)
TRUE,
applet->id);
break;
case PANEL_OBJECT_SEPARATOR:
panel_separator_load_from_gconf (panel_widget,
applet->locked,
applet->position,
applet->id);
default:
break;
}
......
......@@ -35,6 +35,7 @@
#include "panel-applet-frame.h"
#include "panel-action-button.h"
#include "panel-menu-bar.h"
#include "panel-separator.h"
#include "panel-toplevel.h"
#include "panel-menu-button.h"
#include "panel-globals.h"
......@@ -75,6 +76,7 @@ typedef enum {
PANEL_ADDTO_LAUNCHER_NEW,
PANEL_ADDTO_MENU,
PANEL_ADDTO_MENUBAR,
PANEL_ADDTO_SEPARATOR,
PANEL_ADDTO_DRAWER
} PanelAddtoItemType;
......@@ -146,6 +148,17 @@ static PanelAddtoItemInfo internal_addto_items [] = {
"MENUBAR:NEW",
TRUE },
{ PANEL_ADDTO_SEPARATOR,
N_("Separator"),
N_("A separator to organize the panel items"),
NULL,
PANEL_ACTION_NONE,
NULL,
NULL,
NULL,
"SEPARATOR:NEW",
TRUE },
{ PANEL_ADDTO_DRAWER,
N_("Drawer"),
N_("A pop out drawer to store other items in"),
......@@ -775,6 +788,10 @@ panel_addto_add_item (PanelAddtoDialog *dialog,
panel_menu_bar_create (dialog->panel_widget->toplevel,
dialog->insertion_position);
break;
case PANEL_ADDTO_SEPARATOR:
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,
......
......@@ -81,6 +81,7 @@ typedef enum {
PANEL_OBJECT_BONOBO,
PANEL_OBJECT_ACTION,
PANEL_OBJECT_MENU_BAR,
PANEL_OBJECT_SEPARATOR,
/* The following two are for backwards compatibility with 2.0.x */
PANEL_OBJECT_LOGOUT,
PANEL_OBJECT_LOCK
......
......@@ -90,16 +90,17 @@ static GConfEnumStringPair panel_background_type_map [] = {
};
static GConfEnumStringPair panel_object_type_map [] = {
{ PANEL_OBJECT_DRAWER, "drawer-object" },
{ PANEL_OBJECT_MENU, "menu-object" },
{ PANEL_OBJECT_LAUNCHER, "launcher-object" },
{ PANEL_OBJECT_BONOBO, "bonobo-applet" },
{ PANEL_OBJECT_ACTION, "action-applet" },
{ PANEL_OBJECT_MENU_BAR, "menu-bar" },
{ PANEL_OBJECT_DRAWER, "drawer-object" },
{ PANEL_OBJECT_MENU, "menu-object" },
{ PANEL_OBJECT_LAUNCHER, "launcher-object" },
{ PANEL_OBJECT_BONOBO, "bonobo-applet" },
{ PANEL_OBJECT_ACTION, "action-applet" },
{ PANEL_OBJECT_MENU_BAR, "menu-bar" },
{ PANEL_OBJECT_SEPARATOR, "separator" },
/* The following two are for backwards compatibility with 2.0.x */
{ PANEL_OBJECT_LOCK, "lock-object" },
{ PANEL_OBJECT_LOGOUT, "logout-object" },
{ 0, NULL }
{ PANEL_OBJECT_LOCK, "lock-object" },
{ PANEL_OBJECT_LOGOUT, "logout-object" },
{ 0, NULL }
};
static GQuark toplevel_id_quark = 0;
......
/*
* panel-separator.c: panel "Separator" module
*
* Copyright (C) 2005 Carlos Garcia Campos <carlosgc@gnome.org>
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Authors:
* Carlos Garcia Campos <carlosgc@gnome.org>
*/
#include <config.h>
#include "panel-separator.h"
#include "panel-background.h"
#include "panel-profile.h"
#define SEPARATOR_SIZE 10
#define PANEL_SEPARATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_SEPARATOR, PanelSeparatorPrivate))
struct _PanelSeparatorPrivate {
AppletInfo *info;
PanelWidget *panel;
GtkOrientation orientation;
};
G_DEFINE_TYPE (PanelSeparator, panel_separator, GTK_TYPE_EVENT_BOX);
static void
panel_separator_paint (GtkWidget *widget,
GdkRectangle *area)
{
PanelSeparator *separator;
separator = PANEL_SEPARATOR (widget);
if (separator->priv->orientation == GTK_ORIENTATION_HORIZONTAL) {
gtk_paint_vline (widget->style, widget->window,
GTK_WIDGET_STATE (widget),
area, widget, "separator",
widget->style->xthickness,
widget->allocation.height - widget->style->xthickness,
(widget->allocation.width - widget->style->xthickness) / 2);
} else {
gtk_paint_hline (widget->style, widget->window,
GTK_WIDGET_STATE (widget),
area, widget, "separator",
widget->style->ythickness,
widget->allocation.width - widget->style->ythickness,
(widget->allocation.height - widget->style->ythickness) / 2);
}
}
static gboolean
panel_separator_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
if (GTK_WIDGET_DRAWABLE (widget)) {
GTK_WIDGET_CLASS (panel_separator_parent_class)->expose_event (widget, event);
panel_separator_paint (widget, &event->area);
}
return FALSE;
}
static void
panel_separator_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
PanelSeparator *separator;
int size;
separator = PANEL_SEPARATOR (widget);
size = panel_toplevel_get_size (separator->priv->panel->toplevel);
if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL) {
requisition->width = size;
requisition->height = SEPARATOR_SIZE;
} else {
requisition->width = SEPARATOR_SIZE;
requisition->height = size;
}
}
static void
panel_separator_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkAllocation old_allocation;
PanelBackground *background;
old_allocation.x = widget->allocation.x;
old_allocation.y = widget->allocation.y;
old_allocation.width = widget->allocation.width;
old_allocation.height = widget->allocation.height;
GTK_WIDGET_CLASS (panel_separator_parent_class)->size_allocate (widget, allocation);
if (old_allocation.x == allocation->x &&
old_allocation.y == allocation->y &&
old_allocation.width == allocation->width &&
old_allocation.height == allocation->height)
return;
background = &PANEL_SEPARATOR (widget)->priv->panel->background;
if (background->type == PANEL_BACK_NONE ||
(background->type == PANEL_BACK_COLOR && !background->has_alpha))
return;
panel_separator_change_background (PANEL_SEPARATOR (widget));
}
static void
panel_separator_parent_set (GtkWidget *widget,
GtkWidget *previous_parent)
{
PanelSeparator *separator;
separator = PANEL_SEPARATOR (widget);
g_assert (!widget->parent || PANEL_IS_WIDGET (widget->parent));
separator->priv->panel = (PanelWidget *) widget->parent;
}
static void
panel_separator_class_init (PanelSeparatorClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->expose_event = panel_separator_expose_event;
widget_class->size_request = panel_separator_size_request;
widget_class->size_allocate = panel_separator_size_allocate;
widget_class->parent_set = panel_separator_parent_set;
g_type_class_add_private (klass, sizeof (PanelSeparatorPrivate));
}
static void
panel_separator_init (PanelSeparator *separator)
{
separator->priv = PANEL_SEPARATOR_GET_PRIVATE (separator);
separator->priv->info = NULL;
separator->priv->panel = NULL;
separator->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
}
void
panel_separator_set_orientation (PanelSeparator *separator,
PanelOrientation orientation)
{
g_return_if_fail (PANEL_IS_SEPARATOR (separator));
GtkOrientation orient = GTK_ORIENTATION_HORIZONTAL;
switch (orientation) {
case PANEL_ORIENTATION_TOP:
case PANEL_ORIENTATION_BOTTOM:
orient = GTK_ORIENTATION_HORIZONTAL;
break;
case PANEL_ORIENTATION_RIGHT:
case PANEL_ORIENTATION_LEFT:
orient = GTK_ORIENTATION_VERTICAL;
break;
}
if (orient == separator->priv->orientation)
return;
separator->priv->orientation = orient;
gtk_widget_queue_draw (GTK_WIDGET (separator));
}
void
panel_separator_load_from_gconf (PanelWidget *panel,
gboolean locked,
int position,
const char *id)
{
PanelSeparator *separator;
separator = g_object_new (PANEL_TYPE_SEPARATOR, NULL);
separator->priv->info = panel_applet_register (GTK_WIDGET (separator),
NULL, NULL,
panel, locked, position,
TRUE,
PANEL_OBJECT_SEPARATOR,
id);
if (!separator->priv->info) {
gtk_widget_destroy (GTK_WIDGET (separator));
return;
}
panel_widget_set_applet_expandable (panel, GTK_WIDGET (separator),
FALSE, TRUE);
panel_widget_set_applet_size_constrained (panel,
GTK_WIDGET (separator), TRUE);
}
void
panel_separator_create (PanelToplevel *toplevel,
int position)
{
char *id;
id = panel_profile_prepare_object (PANEL_OBJECT_SEPARATOR,
toplevel, position, FALSE);
panel_profile_add_to_list (PANEL_GCONF_OBJECTS, id);
g_free (id);
}
void
panel_separator_change_background (PanelSeparator *separator)
{
panel_background_change_background_on_widget (&separator->priv->panel->background,
GTK_WIDGET (separator));
}
/*
* panel-separator.h: panel "Separator" module
*
* Copyright (C) 2005 Carlos Garcia Campos <carlosgc@gnome.org>
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Authors:
* Carlos Garcia Campos <carlosgc@gnome.org>
*/
#ifndef PANEL_SEPARATOR_H
#define PANEL_SEPARATOR_H
#include "applet.h"
#include "panel-widget.h"
G_BEGIN_DECLS
#define PANEL_TYPE_SEPARATOR (panel_separator_get_type ())
#define PANEL_SEPARATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_SEPARATOR, PanelSeparator))
#define PANEL_SEPARATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_SEPARATOR, PanelSeparatorClass))
#define PANEL_IS_SEPARATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_SEPARATOR))
#define PANEL_IS_SEPARATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_SEPARATOR))
#define PANEL_SEPARATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_SEPARATOR, PanelSeparatorClass))
typedef struct _PanelSeparator PanelSeparator;
typedef struct _PanelSeparatorClass PanelSeparatorClass;
typedef struct _PanelSeparatorPrivate PanelSeparatorPrivate;
struct _PanelSeparator {
GtkEventBox parent;
PanelSeparatorPrivate *priv;
};
struct _PanelSeparatorClass {
GtkEventBoxClass parent_class;
};
GType panel_separator_get_type (void) G_GNUC_CONST;
void panel_separator_create (PanelToplevel *toplevel,
int position);
void panel_separator_load_from_gconf (PanelWidget *panel_widget,
gboolean locked,
gint position,
const char *id);
void panel_separator_set_orientation (PanelSeparator *separator,
PanelOrientation orientation);
void panel_separator_change_background (PanelSeparator *separator);
G_END_DECLS
#endif /* PANEL_SEPARATOR_H */
......@@ -39,6 +39,7 @@
#include "panel-applet-frame.h"
#include "panel-action-button.h"
#include "panel-menu-bar.h"
#include "panel-separator.h"
#include "panel-compatibility.h"
#include "panel-multiscreen.h"
#include "panel-toplevel.h"
......@@ -96,6 +97,10 @@ orientation_change (AppletInfo *info,
panel_widget);
}
break;
case PANEL_OBJECT_SEPARATOR:
panel_separator_set_orientation (PANEL_SEPARATOR (info->widget),
orientation);
break;
default:
break;
}
......@@ -160,6 +165,9 @@ back_change (AppletInfo *info,
case PANEL_OBJECT_MENU_BAR:
panel_menu_bar_change_background (PANEL_MENU_BAR (info->widget));
break;
case PANEL_OBJECT_SEPARATOR:
panel_separator_change_background (PANEL_SEPARATOR (info->widget));
break;
default:
break;
}
......@@ -774,6 +782,14 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
success = FALSE;
}
} else if (!strcmp(applet_type,"SEPARATOR:NEW")) {
if (panel_profile_id_lists_are_writable ()) {
panel_separator_create (panel->toplevel, pos);
success = TRUE;
} else {
success = FALSE;
}
} else if (!strcmp(applet_type,"LAUNCHER:ASK")) {
if (panel_profile_id_lists_are_writable ()) {
ask_about_launcher (NULL, panel, pos, TRUE);
......
Supports Markdown
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