Example #1
0
static gboolean
fish_applet_fill (FishApplet *fish)
{
	PanelApplet *applet = (PanelApplet *) fish;

	fish->orientation = panel_applet_get_orient (applet);

	fish->settings = panel_applet_settings_new (applet, FISH_SCHEMA);
	fish->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);

	g_signal_connect (fish->settings, "changed", G_CALLBACK (fish_applet_settings_changed), fish);
	/* NULL means we will update for all settings */
	fish_applet_settings_changed (fish->settings, NULL, fish);

	/*gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);*/

	panel_applet_setup_menu_from_resource (applet,
	                                       FISH_RESOURCE_PATH "fish-menu.xml");
	panel_applet_setup_menu_action_entries (applet,
	                                        fish_menu_actions,
	                                        G_N_ELEMENTS (fish_menu_actions),
	                                        fish);

	GSimpleAction *preferences = panel_applet_get_menu_action (applet, "preferences");
	g_object_bind_property (applet, "locked-down",
	                        preferences, "enabled",
	                        G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);

	setup_fish_widget (fish);

	return TRUE;
}
Example #2
0
static void
cpufreq_applet_init (CPUFreqApplet *applet)
{
        applet->prefs = NULL;
        applet->popup = NULL;
        applet->monitor = NULL;

        applet->label = gtk_label_new (NULL);
        applet->unit_label = gtk_label_new (NULL);
        applet->icon = gtk_image_new ();
        applet->box = NULL;

	applet->show_mode = CPUFREQ_MODE_BOTH;
	applet->show_text_mode = CPUFREQ_MODE_TEXT_FREQUENCY_UNIT;
	
	applet->need_refresh = TRUE;

        panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);

        applet->orient = panel_applet_get_orient (PANEL_APPLET (applet));

	switch (applet->orient) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		applet->container = gtk_alignment_new (0.5, 0.5, 0, 0);
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
		applet->container = gtk_alignment_new (0, 0.5, 0, 0);
		break;
	}

	gtk_container_add (GTK_CONTAINER (applet), applet->container);
	gtk_widget_show (applet->container);
}
Example #3
0
static void
window_menu_size_allocate (PanelApplet	 *applet, 
			   GtkAllocation *allocation,
			   WindowMenu	 *window_menu)
{
	PanelAppletOrient  orient;
	GList             *children;
	GtkWidget         *child;

	orient = panel_applet_get_orient (applet);

	children = gtk_container_get_children (GTK_CONTAINER (window_menu->selector));
	child = GTK_WIDGET (children->data);
	g_list_free (children);

	if (orient == PANEL_APPLET_ORIENT_LEFT || 
	    orient == PANEL_APPLET_ORIENT_RIGHT) {
		if (window_menu->size == allocation->width &&
		    orient == window_menu->orient)
			return;
		window_menu->size = allocation->width;
		gtk_widget_set_size_request (child, window_menu->size, -1);
	} else {
		if (window_menu->size == allocation->height &&
		    orient == window_menu->orient)
			return;
		window_menu->size = allocation->height;
		gtk_widget_set_size_request (child, -1, window_menu->size);
	}

	window_menu->orient = orient;
}
Example #4
0
/**
 * gpm_applet_size_allocate_cb:
 * @applet: Inhibit applet instance
 *
 * resize icon when panel size changed
 **/
static void
gpm_applet_size_allocate_cb (GtkWidget    *widget,
                             GdkRectangle *allocation)
{
	GpmInhibitApplet *applet = GPM_INHIBIT_APPLET (widget);
	int               size = NULL;

	switch (panel_applet_get_orient (PANEL_APPLET (applet))) {
		case PANEL_APPLET_ORIENT_LEFT:
		case PANEL_APPLET_ORIENT_RIGHT:
			size = allocation->width;
			break;

		case PANEL_APPLET_ORIENT_UP:
		case PANEL_APPLET_ORIENT_DOWN:
			size = allocation->height;
			break;
	}

	/* copied from button-widget.c in the panel */
	if (size < 22)
		size = 16;
	else if (size < 24)
		size = 22;
	else if (size < 32)
		size = 24;
	else if (size < 48)
		size = 32;
	else
		size = 48;

	/* GtkImage already contains a check to do nothing if it's the same */
	gtk_image_set_pixel_size (GTK_IMAGE(applet->image), size);
}
Example #5
0
GnocamApplet *
gnocam_applet_new (PanelApplet *applet)
{
	GnocamApplet *a;
	GtkWidget *w;
	GConfClient *client;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);

	a = g_object_new (GNOCAM_TYPE_APPLET, NULL);
	a->priv->applet = applet;

	client = gconf_client_get_default ();
	gconf_client_notify_add (client, "/desktop/gnome/cameras", 
				 notify_func, a, NULL, NULL);
	g_object_unref (G_OBJECT (client));

	/* Setup menu. */
	panel_applet_setup_menu_from_file (applet, UIDIR,
		"GNOME_GnocamApplet.xml", NULL, gnocam_applet_menu_verbs, a);

	/* Setup widget. */
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		w = gtk_vbox_new (FALSE, 0);
		break;
	default:
		w = gtk_hbox_new (FALSE, 0);
		break;
	}
	gtk_widget_show (w);
	gtk_container_add (GTK_CONTAINER (a->priv->applet), w);
	a->priv->box = GTK_BOX (w);
	a->priv->image= gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD,
						  GTK_ICON_SIZE_BUTTON);
	gtk_widget_show (a->priv->image);
	gtk_box_pack_start (GTK_BOX (w), a->priv->image, FALSE, FALSE, 0);

	/* Setup the applet. */
	g_signal_connect (applet, "change_orient",
			  G_CALLBACK (on_change_orient), a);
	g_signal_connect (applet, "change_size",
			  G_CALLBACK (on_change_size), a);
	g_signal_connect (applet, "change_background",
			  G_CALLBACK (on_change_background), a);
	g_signal_connect (applet, "move_focus_out_of_applet",
			  G_CALLBACK (on_move_focus_out_of_applet), a);

	gtk_widget_show (GTK_WIDGET (a->priv->applet));

	gnocam_applet_load_preferences (a);

	return (a);
}
Example #6
0
static GtkSizeRequestMode
panel_applet_get_request_mode (GtkWidget *widget)
{
        PanelApplet       *applet      = PANEL_APPLET (widget);
        PanelAppletOrient  orientation = panel_applet_get_orient (applet);

        if (orientation == PANEL_APPLET_ORIENT_UP || orientation == PANEL_APPLET_ORIENT_DOWN)
                return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;

        return GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
}
static gboolean get_applet_vert(PanelApplet *applet)
{
    switch (panel_applet_get_orient(applet)) {
    case PANEL_APPLET_ORIENT_UP:
    case PANEL_APPLET_ORIENT_DOWN:
	return FALSE;
	break;
    default:
	return TRUE;
	break;
    }
}
Example #8
0
static void
panel_applet_get_preferred_height (GtkWidget *widget,
                                  int       *minimum_height,
                                  int       *natural_height)
{
	PanelApplet *applet       = PANEL_APPLET (widget);
	GtkBin      *bin          = GTK_BIN (widget);
	GtkWidget   *child        = NULL;
	gint         focus_width  = 0;
	guint        border_width = 0;

	if (!applet->priv->has_handle) {
		GTK_WIDGET_CLASS (panel_applet_parent_class)->get_preferred_height (widget, minimum_height, natural_height);
	} else {
		child = gtk_bin_get_child (bin);

		if (child && gtk_widget_get_visible (child))
			gtk_widget_get_preferred_height (child, minimum_height, natural_height);

		border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
		*minimum_height += border_width;
		*natural_height += border_width;

		switch (panel_applet_get_orient (applet)) {
			case PANEL_APPLET_ORIENT_UP:
			case PANEL_APPLET_ORIENT_DOWN:
				*minimum_height += HANDLE_SIZE;
				*natural_height += HANDLE_SIZE;
				break;
			case PANEL_APPLET_ORIENT_LEFT:
			case PANEL_APPLET_ORIENT_RIGHT:
				break;
			default:
				g_assert_not_reached ();
				break;
		}
	}

	if (!panel_applet_can_focus (widget))
		return;

	/* We are deliberately ignoring focus-padding here to
	 * save valuable panel real estate.
	 */
	gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);

	*minimum_height += 2 * focus_width;
	*natural_height += 2 * focus_width;
}
static gboolean
bigboard_button_applet_fill (PanelApplet *applet)
{
        ButtonData *button_data;

#ifdef GUI_LOG
        log_debug_messages = TRUE;
#endif
        
        g_log_set_default_handler(log_handler, NULL);
        g_log_set_handler(G_LOG_DOMAIN,
                          (GLogLevelFlags) (G_LOG_LEVEL_DEBUG | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
                          log_handler, NULL);

        panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);

        button_data = bigboard_button_add_to_widget (GTK_WIDGET (applet));

        g_debug ("Got panel applet size %d", panel_applet_get_size (applet));
        update_size (button_data,
                     panel_applet_get_size (applet));

        update_orientation (button_data,
                            panel_applet_get_orient (applet));

        /* FIXME: Update this comment. */
        /* we have to bind change_orient before we do applet_widget_add
           since we need to get an initial change_orient signal to set our
           initial oriantation, and we get that during the _add call */
        g_signal_connect (G_OBJECT (button_data->applet),
                          "change_orient",
                          G_CALLBACK (applet_change_orient),
                          button_data);

        panel_applet_set_background_widget (PANEL_APPLET (button_data->applet),
                                            GTK_WIDGET (button_data->applet));

        panel_applet_setup_menu_from_file (PANEL_APPLET (button_data->applet),
                                           NULL,
                                           "GNOME_OnlineDesktop_BigBoardButtonApplet.xml",
                                           NULL,
                                           bigboard_button_menu_verbs,
                                           button_data);

        gtk_widget_show_all (button_data->applet);

        return TRUE;
}
Example #10
0
static void
cpufreq_applet_popup_position_menu (GtkMenu  *menu,
                                    int      *x,
                                    int      *y,
                                    gboolean *push_in,
                                    gpointer  gdata)
{
        GtkWidget      *widget;
        GtkRequisition  requisition;
        GtkAllocation   allocation;
        gint            menu_xpos;
        gint            menu_ypos;

        widget = GTK_WIDGET (gdata);

        gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);

        gdk_window_get_origin (gtk_widget_get_window (widget), &menu_xpos, &menu_ypos);

	gtk_widget_get_allocation (widget, &allocation);

        menu_xpos += allocation.x;
        menu_ypos += allocation.y;

        switch (panel_applet_get_orient (PANEL_APPLET (widget))) {
        case PANEL_APPLET_ORIENT_DOWN:
        case PANEL_APPLET_ORIENT_UP:
                if (menu_ypos > gdk_screen_get_height (gtk_widget_get_screen (widget)) / 2)
                        menu_ypos -= requisition.height;
                else
                        menu_ypos += allocation.height;
                break;
        case PANEL_APPLET_ORIENT_RIGHT:
        case PANEL_APPLET_ORIENT_LEFT:
                if (menu_xpos > gdk_screen_get_width (gtk_widget_get_screen (widget)) / 2)
                        menu_xpos -= requisition.width;
                else
                        menu_xpos += allocation.width;
                break;
        default:
                g_assert_not_reached ();
        }

        *x = menu_xpos;
        *y = menu_ypos;
        *push_in = TRUE;
}
Example #11
0
gboolean
window_menu_applet_fill (PanelApplet *applet)
{
	WindowMenu *window_menu;

	window_menu = g_new0 (WindowMenu, 1);

	window_menu->applet = GTK_WIDGET (applet);
	force_no_focus_padding (window_menu->applet);
	gtk_widget_set_tooltip_text (window_menu->applet, _("Window Selector"));
 
	panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
	window_menu->size = panel_applet_get_size (applet);
	window_menu->orient = panel_applet_get_orient (applet);

	g_signal_connect (window_menu->applet, "destroy",
			  G_CALLBACK (window_menu_destroy), window_menu);

	window_menu->selector = wnck_selector_new ();
	gtk_container_add (GTK_CONTAINER (window_menu->applet), 
			   window_menu->selector);

	panel_applet_set_background_widget (PANEL_APPLET (window_menu->applet),
					    GTK_WIDGET (window_menu->selector));

	g_signal_connect (window_menu->applet, "key_press_event",
			  G_CALLBACK (window_menu_key_press_event), window_menu);
	g_signal_connect (window_menu->applet, "size-allocate",
			  G_CALLBACK (window_menu_size_allocate), window_menu);

	g_signal_connect_after (G_OBJECT (window_menu->applet), "focus-in-event",
				G_CALLBACK (gtk_widget_queue_draw), window_menu);
	g_signal_connect_after (G_OBJECT (window_menu->applet), "focus-out-event",
				G_CALLBACK (gtk_widget_queue_draw), window_menu);
	g_signal_connect_after (G_OBJECT (window_menu->selector), "draw",
				G_CALLBACK (window_menu_on_draw), window_menu);

	g_signal_connect (G_OBJECT (window_menu->selector), "button_press_event",
			  G_CALLBACK (filter_button_press), window_menu);

	gtk_widget_show_all (GTK_WIDGET (window_menu->applet));

	return TRUE;
}
Example #12
0
static GtkOrientation
get_orientation_from_applet (PanelApplet *applet)
{
  GtkOrientation orientation;

  switch (panel_applet_get_orient (applet))
    {
    case PANEL_APPLET_ORIENT_LEFT:
    case PANEL_APPLET_ORIENT_RIGHT:
      orientation = GTK_ORIENTATION_VERTICAL;
      break;
    case PANEL_APPLET_ORIENT_UP:
    case PANEL_APPLET_ORIENT_DOWN:
    default:
      orientation = GTK_ORIENTATION_HORIZONTAL;
      break;
    }

  return orientation;
}
Example #13
0
static void
trash_applet_size_allocate (GtkWidget    *widget,
                            GdkRectangle *allocation)
{
  TrashApplet *applet = TRASH_APPLET (widget);

  switch (panel_applet_get_orient (PANEL_APPLET (applet)))
  {
    case PANEL_APPLET_ORIENT_LEFT:
    case PANEL_APPLET_ORIENT_RIGHT:
      trash_applet_set_icon_size (applet, allocation->width);
      break;

    case PANEL_APPLET_ORIENT_UP:
    case PANEL_APPLET_ORIENT_DOWN:
      trash_applet_set_icon_size (applet, allocation->height);
      break;
  }

  GTK_WIDGET_CLASS (trash_applet_parent_class)
    ->size_allocate (widget, allocation);
}
Example #14
0
static void
megaphone_applet_size_allocate_cb (GtkWidget       *widget,
				   GtkAllocation   *allocation,
				   MegaphoneApplet *applet)
{
	MegaphoneAppletPriv *priv = GET_PRIV (applet);
	gint                 size;
	PanelAppletOrient    orient;

	orient = panel_applet_get_orient (PANEL_APPLET (widget));
	if (orient == PANEL_APPLET_ORIENT_LEFT ||
	    orient == PANEL_APPLET_ORIENT_RIGHT) {
		size = allocation->width;
	} else {
		size = allocation->height;
	}

	if (size != priv->image_size) {
		priv->image_size = size;
		megaphone_applet_update_icon (applet);
	}
}
Example #15
0
gboolean
window_list_applet_fill (PanelApplet *applet)
{
	TasklistData *tasklist;
	GtkActionGroup *action_group;
	GtkAction *action;
	gchar *ui_path;

	tasklist = g_new0 (TasklistData, 1);

	tasklist->applet = GTK_WIDGET (applet);

	panel_applet_set_flags (PANEL_APPLET (tasklist->applet),
				PANEL_APPLET_EXPAND_MAJOR |
				PANEL_APPLET_EXPAND_MINOR |
				PANEL_APPLET_HAS_HANDLE);

	panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL);

	setup_gconf (tasklist);

	tasklist->include_all_workspaces = g_settings_get_boolean (tasklist->settings, "display-all-workspaces");
	tasklist->grouping = g_settings_get_enum (tasklist->settings, "group-windows");
	tasklist->move_unminimized_windows = g_settings_get_boolean (tasklist->settings, "move-unminimized-windows");

	tasklist->size = panel_applet_get_size (applet);
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		tasklist->orientation = GTK_ORIENTATION_VERTICAL;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
	default:
		tasklist->orientation = GTK_ORIENTATION_HORIZONTAL;
		break;
	}

	tasklist->tasklist = wnck_tasklist_new ();

        wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist),
                                       icon_loader_func,
                                       tasklist,
                                       NULL);
        
	g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy",
			  G_CALLBACK (destroy_tasklist),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet), "size_allocate",
			  G_CALLBACK (applet_size_allocate),
			  tasklist);
	tasklist_update (tasklist);
	gtk_widget_show (tasklist->tasklist);

	gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist);

	g_signal_connect (G_OBJECT (tasklist->applet),
			  "realize",
			  G_CALLBACK (applet_realized),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_orient",
			  G_CALLBACK (applet_change_orient),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_size",
			  G_CALLBACK (applet_change_pixel_size),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_background",
			  G_CALLBACK (applet_change_background),
			  tasklist);

	panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet),
					    GTK_WIDGET (tasklist->applet));

	action_group = gtk_action_group_new ("Tasklist Applet Actions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group,
				      tasklist_menu_actions,
				      G_N_ELEMENTS (tasklist_menu_actions),
				      tasklist);
	ui_path = g_build_filename (WNCK_MENU_UI_DIR, "window-list-menu.xml", NULL);
	panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet),
					   ui_path, action_group);
	g_free (ui_path);

	action = gtk_action_group_get_action (action_group, "TasklistPreferences");
	g_object_bind_property (tasklist->applet, "locked-down",
				action, "visible",
				G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);

	g_object_unref (action_group);

	gtk_widget_show (tasklist->applet);
	
	return TRUE;
}
Example #16
0
static void
panel_applet_size_allocate (GtkWidget     *widget,
			    GtkAllocation *allocation)
{
	PanelApplet   *applet;
	GtkAllocation  child_allocation;
	GtkAllocation  widget_allocation;
	GtkBin        *bin;
	GtkWidget     *child;
	GdkWindow     *window;
	int            border_width;
	int            focus_width = 0;

	applet = PANEL_APPLET (widget);
	bin    = GTK_BIN (widget);

	gtk_widget_get_allocation (widget, &widget_allocation);

	if (!panel_applet_can_focus (widget) && !applet->priv->has_handle) {
		GTK_WIDGET_CLASS (panel_applet_parent_class)->size_allocate (widget, allocation);
	} else {
		gtk_widget_set_allocation (widget, allocation);

		border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
		window = gtk_widget_get_window (widget);
		
		/*
		 * We are deliberately ignoring focus-padding here to
		 * save valuable panel real estate.
		 */
		gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);

		child_allocation.x      = allocation->x;
		child_allocation.y      = allocation->y;
		child_allocation.width  = allocation->width;
		child_allocation.height = allocation->height;

		if (applet->priv->has_handle) {
			applet->priv->handle_rect.x = 0;
			applet->priv->handle_rect.y = 0;

			switch (panel_applet_get_orient (applet)) {
				case PANEL_APPLET_ORIENT_UP:
				case PANEL_APPLET_ORIENT_DOWN:
					applet->priv->handle_rect.width  = HANDLE_SIZE;
					applet->priv->handle_rect.height = allocation->height;

					if (gtk_widget_get_direction (GTK_WIDGET (applet)) != GTK_TEXT_DIR_RTL) {
						applet->priv->handle_rect.x = 0;
						child_allocation.x = HANDLE_SIZE;
					} else {
						applet->priv->handle_rect.x = allocation->width - HANDLE_SIZE;
						child_allocation.x = 0;
					}

					child_allocation.y      = 0;
					child_allocation.width  = allocation->width - HANDLE_SIZE;
					child_allocation.height = allocation->height;
					break;
				case PANEL_APPLET_ORIENT_LEFT:
				case PANEL_APPLET_ORIENT_RIGHT:
					applet->priv->handle_rect.width  = allocation->width;
					applet->priv->handle_rect.height = HANDLE_SIZE;

					child_allocation.x      = 0;
					child_allocation.y      = HANDLE_SIZE;
					child_allocation.width  = allocation->width;
					child_allocation.height = allocation->height - HANDLE_SIZE;
					break;
				default:
					g_assert_not_reached ();
					break;
			}

			child_allocation.width  = MAX (1, child_allocation.width);
			child_allocation.height = MAX (1, child_allocation.height);
		}

		if (panel_applet_can_focus (widget)) {
			child_allocation.x += focus_width;
			child_allocation.y += focus_width;
		}
		
		child_allocation.width  = MAX (child_allocation.width  - border_width * 2, 0);
		child_allocation.height = MAX (child_allocation.height - border_width * 2, 0);
		
		if (gtk_widget_get_realized (widget)) {
			gdk_window_move_resize (window,
				allocation->x + border_width,
				allocation->y + border_width,
				MAX (allocation->width - border_width * 2, 0),
				MAX (allocation->height - border_width * 2, 0));
		}
		
		if (panel_applet_can_focus (widget)) {
			child_allocation.width  = MAX (child_allocation.width  - 2 * focus_width, 0);
			child_allocation.height = MAX (child_allocation.height - 2 * focus_width, 0);
		}

		child = gtk_bin_get_child (bin);
		if (child && gtk_widget_get_visible (child))
			gtk_widget_size_allocate (child, &child_allocation);
	}
}
gboolean
window_list_applet_fill (PanelApplet *applet)
{
	TasklistData *tasklist;
	GError *error;
	GConfValue *value;

	gint sizepref;

	tasklist = g_new0 (TasklistData, 1);

	tasklist->applet = GTK_WIDGET (applet);

	panel_applet_set_flags (PANEL_APPLET (tasklist->applet),
				PANEL_APPLET_EXPAND_MAJOR |
				PANEL_APPLET_EXPAND_MINOR |
				PANEL_APPLET_HAS_HANDLE);

	panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL);

	setup_gconf (tasklist);

	error = NULL;
	tasklist->include_all_workspaces = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error);
	if (error) {
		g_error_free (error);
		tasklist->include_all_workspaces = FALSE; /* Default value */
	}

	error = NULL;
	tasklist->grouping = -1;
	value = panel_applet_gconf_get_value (applet, "group_windows", &error);
	if (error) {
		g_error_free (error);
	} else if (value) {
		tasklist->grouping = get_grouping_type (value);
		gconf_value_free (value);
	}
	if (tasklist->grouping < 0)
		tasklist->grouping = WNCK_TASKLIST_AUTO_GROUP; /* Default value */
	
	error = NULL;
	tasklist->move_unminimized_windows = panel_applet_gconf_get_bool (applet, "move_unminimized_windows", &error);
	if (error) {
		g_error_free (error);
		tasklist->move_unminimized_windows = TRUE; /* Default value */
	}

	tasklist->size = panel_applet_get_size (applet);
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		tasklist->orientation = GTK_ORIENTATION_VERTICAL;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
	default:
		tasklist->orientation = GTK_ORIENTATION_HORIZONTAL;
		break;
	}

	tasklist->screen = wncklet_get_screen (tasklist->applet);

	/* because the tasklist doesn't respond to signals at the moment */
	wnck_screen_force_update (tasklist->screen);

	tasklist->tasklist = wnck_tasklist_new (tasklist->screen);

        wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist),
                                       icon_loader_func,
                                       tasklist,
                                       NULL);
        
	/* get size preferences */
	error = NULL;
	sizepref = panel_applet_gconf_get_int (applet, "minimum_size", &error);
	if (error) {
		sizepref = 50; /* Default value */
		g_error_free (error);
	}

	if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL)
		wnck_tasklist_set_minimum_width (WNCK_TASKLIST (tasklist->tasklist), sizepref);	  
	else
		wnck_tasklist_set_minimum_height (WNCK_TASKLIST (tasklist->tasklist), sizepref);	  

	error = NULL;
	sizepref = panel_applet_gconf_get_int (applet, "maximum_size", &error);
	if (error) {
		sizepref = 4096; /* Default value */
		g_error_free (error);
	}

	tasklist->maximum_size = sizepref;

	g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy",
			  G_CALLBACK (destroy_tasklist),
			  tasklist);

	g_signal_connect (G_OBJECT (tasklist->applet), "size_request",
			  G_CALLBACK (applet_size_request),
			  tasklist);
	tasklist_update (tasklist);
	gtk_widget_show (tasklist->tasklist);

	gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist);

	g_signal_connect (G_OBJECT (tasklist->applet),
			  "realize",
			  G_CALLBACK (applet_realized),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_orient",
			  G_CALLBACK (applet_change_orient),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_size",
			  G_CALLBACK (applet_change_pixel_size),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_background",
			  G_CALLBACK (applet_change_background),
			  tasklist);

	panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet),
					    GTK_WIDGET (tasklist->applet));
	
	panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet),
					   NULL,
					   "GNOME_WindowListApplet.xml",
					   NULL,
					   tasklist_menu_verbs, 
					   tasklist);

	if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) {
		BonoboUIComponent *popup_component;

		popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet));

		bonobo_ui_component_set_prop (popup_component,
					      "/commands/TasklistPreferences",
					      "hidden", "1",
					      NULL);
	}

	gtk_widget_show (tasklist->applet);
	
	return TRUE;
}
void gweather_applet_create (GWeatherApplet *gw_applet)
{
    GtkActionGroup *action_group;
    gchar          *ui_path;
    AtkObject      *atk_obj;

    gw_applet->gweather_pref.location = NULL;
    gw_applet->gweather_pref.update_interval = 1800;
    gw_applet->gweather_pref.update_enabled = TRUE;
    gw_applet->gweather_pref.detailed = FALSE;
    gw_applet->gweather_pref.radar_enabled = TRUE;
    gw_applet->gweather_pref.temperature_unit = TEMP_UNIT_INVALID;
    gw_applet->gweather_pref.speed_unit = SPEED_UNIT_INVALID;
    gw_applet->gweather_pref.pressure_unit = PRESSURE_UNIT_INVALID;
    gw_applet->gweather_pref.distance_unit = DISTANCE_UNIT_INVALID;
    
    panel_applet_set_flags (gw_applet->applet, PANEL_APPLET_EXPAND_MINOR);

    panel_applet_set_background_widget(gw_applet->applet,
                                       GTK_WIDGET(gw_applet->applet));

    g_set_application_name (_("Weather Report"));

    gtk_window_set_default_icon_name ("weather-storm");

    gw_applet->container = gtk_alignment_new (0.5, 0.5, 0, 0);
    gtk_container_add (GTK_CONTAINER (gw_applet->applet), gw_applet->container);

    g_signal_connect (G_OBJECT(gw_applet->applet), "change_orient",
                       G_CALLBACK(change_orient_cb), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "size_allocate",
                       G_CALLBACK(size_allocate_cb), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "destroy", 
                       G_CALLBACK (applet_destroy), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "button_press_event",
                       G_CALLBACK(clicked_cb), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "key_press_event",           
			G_CALLBACK(key_press_cb), gw_applet);
                     
    gtk_widget_set_tooltip_text (GTK_WIDGET(gw_applet->applet), _("GNOME Weather"));

    atk_obj = gtk_widget_get_accessible (GTK_WIDGET (gw_applet->applet));
    if (GTK_IS_ACCESSIBLE (atk_obj))
	   atk_object_set_name (atk_obj, _("GNOME Weather"));

    gw_applet->size = panel_applet_get_size (gw_applet->applet);

    gw_applet->orient = panel_applet_get_orient (gw_applet->applet);

    action_group = gtk_action_group_new ("GWeather Applet Actions");
    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
    gtk_action_group_add_actions (action_group,
				  weather_applet_menu_actions,
				  G_N_ELEMENTS (weather_applet_menu_actions),
				  gw_applet);
    ui_path = g_build_filename (GWEATHER_MENU_UI_DIR, "gweather-applet-menu.xml", NULL);
    panel_applet_setup_menu_from_file (gw_applet->applet,
				       ui_path, action_group);
    g_free (ui_path);

    if (panel_applet_get_locked_down (gw_applet->applet)) {
	    GtkAction *action;

	    action = gtk_action_group_get_action (action_group, "Props");
	    gtk_action_set_visible (action, FALSE);
    }
    g_object_unref (action_group);
	
    place_widgets(gw_applet);        

#ifdef HAVE_NETWORKMANAGER
    setup_network_monitor (gw_applet);     
#endif
}
Example #19
0
static void
setup_widgets (WirelessApplet *applet)
{
	GtkRequisition req;
	gint total_size = 0;
	gboolean horizontal = FALSE;
	gint panel_size;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	GtkWidget *viewport;
	
	panel_size = panel_applet_get_size (PANEL_APPLET (applet));
	
	switch (panel_applet_get_orient(PANEL_APPLET (applet))) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		horizontal = FALSE;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
		horizontal = TRUE;
		break;
	}

	/* construct pixmap widget */
	applet->pixmap = gtk_image_new ();
	gtk_image_set_from_pixbuf (GTK_IMAGE (applet->pixmap), applet->pixmaps[PIX_BROKEN]);
	gtk_widget_size_request (applet->pixmap, &req);
	gtk_widget_show (applet->pixmap);

	if (horizontal)
		total_size += req.height;
	else
		total_size += req.width;

	/* construct pct widget */
	applet->pct_label = gtk_label_new ("N/A");

	if (applet->show_percent == TRUE) {
		gtk_widget_show (applet->pct_label);
		gtk_widget_size_request (applet->pct_label, &req);
		if (horizontal)
			total_size += req.height;
		else
			total_size += req.width;
	}

	/* construct ap popup window */
	applet->ap_popup = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_type_hint (GTK_WINDOW (applet->ap_popup),
				  GDK_WINDOW_TYPE_HINT_DOCK);
	gtk_window_set_resizable (GTK_WINDOW (applet->ap_popup),
				  FALSE);
	gtk_window_stick (GTK_WINDOW (applet->ap_popup));
	gtk_window_set_default_size (GTK_WINDOW (applet->ap_popup),
				     0, 0);
	gtk_window_set_decorated (GTK_WINDOW (applet->ap_popup), FALSE);

	applet->ap_store = gtk_list_store_new (1, wireless_ap_get_type());
	gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (applet->ap_store),
					 0,
					 ap_compare_func,
					 applet,
					 NULL);
	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (applet->ap_store),
					      0, GTK_SORT_DESCENDING);
	
	applet->ap_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (applet->ap_store));
	g_signal_connect (applet->ap_view, "row_activated",
			  G_CALLBACK (wireless_applet_row_activate_cb),
			  applet);
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (applet->ap_view),
				      FALSE);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (applet->ap_view),
					   FALSE);
	
	/* the quality column */
	renderer = GTK_CELL_RENDERER (ephy_cell_renderer_progress_new ());
	column = gtk_tree_view_column_new_with_attributes ("Quality",
							   renderer,
							   NULL);
	gtk_tree_view_column_set_cell_data_func (column, renderer,
						 ap_quality_cell_data_cb,
						 applet, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (applet->ap_view),
				     column);

	viewport = gtk_viewport_new (NULL, NULL);
	gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport),
				      GTK_SHADOW_ETCHED_IN);
	
	gtk_container_add (GTK_CONTAINER (viewport), applet->ap_view);
	gtk_container_add (GTK_CONTAINER(applet->ap_popup), viewport);

	gtk_widget_show_all (viewport);
	
	/* the essid column */
	renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
	column = gtk_tree_view_column_new_with_attributes ("ESSID",
							   renderer,
							   NULL);
	gtk_tree_view_column_set_cell_data_func (column, renderer,
						 ap_essid_cell_data_cb,
						 applet, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (applet->ap_view),
				     column);

	/* encryption column */
	renderer = GTK_CELL_RENDERER (gtk_cell_renderer_pixbuf_new ());
	column = gtk_tree_view_column_new_with_attributes ("Encryption",
							   renderer,
							   NULL);
	gtk_tree_view_column_set_cell_data_func (column, renderer,
						 ap_encryption_cell_data_cb,
						 applet, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (applet->ap_view),
				     column);
	
	/* pack */
	if (applet->button)
		gtk_widget_destroy (applet->button);

	if (horizontal && (total_size <= panel_size))
		applet->box = gtk_vbox_new (FALSE, 0);
	else if (horizontal && (total_size > panel_size))
		applet->box = gtk_hbox_new (FALSE, 0);
	else if (!horizontal && (total_size <= panel_size))
		applet->box = gtk_hbox_new (FALSE, 0);
	else 
		applet->box = gtk_vbox_new (FALSE, 0);

	applet->button = gtk_toggle_button_new ();
	g_signal_connect(applet->button, "toggled",
			 G_CALLBACK(applet_button_toggled), applet);
	gtk_button_set_relief (GTK_BUTTON (applet->button), GTK_RELIEF_NONE);
	gtk_container_add (GTK_CONTAINER(applet->button), applet->box);
	
	gtk_box_pack_start (GTK_BOX (applet->box), applet->pixmap, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (applet->box), applet->pct_label, TRUE, TRUE, 0);
	/* note, I don't use show_all, because this way the percent label is
	 * only realised if it's enabled */
	gtk_widget_show (applet->button);
	gtk_widget_show (applet->box);
	gtk_container_add (GTK_CONTAINER (applet), applet->button);

	applet->current_pixbuf = NULL;
	applet->about_dialog = NULL;
}
gboolean
show_desktop_applet_fill (PanelApplet *applet)
{
        ShowDesktopData *sdd;
	AtkObject       *atk_obj;
        BonoboUIComponent* popup_component;

	panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);

        sdd = g_new0 (ShowDesktopData, 1);

        sdd->applet = GTK_WIDGET (applet);

	sdd->image = gtk_image_new ();

        switch (panel_applet_get_orient (applet)) {
        case PANEL_APPLET_ORIENT_LEFT:
        case PANEL_APPLET_ORIENT_RIGHT:
                sdd->orient = GTK_ORIENTATION_VERTICAL;
                break;
        case PANEL_APPLET_ORIENT_UP:
        case PANEL_APPLET_ORIENT_DOWN:
        default:
                sdd->orient = GTK_ORIENTATION_HORIZONTAL;
                break;
        }

        sdd->size = panel_applet_get_size (PANEL_APPLET (sdd->applet));

	g_signal_connect (G_OBJECT (sdd->applet), "realize",
			  G_CALLBACK (show_desktop_applet_realized), sdd);

        sdd->button = gtk_toggle_button_new ();

	gtk_widget_set_name (sdd->button, "showdesktop-button");
	gtk_rc_parse_string ("\n"
			     "   style \"showdesktop-button-style\"\n"
			     "   {\n"
			     "      GtkWidget::focus-line-width=0\n"
			     "      GtkWidget::focus-padding=0\n"
			     "   }\n"
			     "\n"
			     "    widget \"*.showdesktop-button\" style \"showdesktop-button-style\"\n"
			     "\n");

	atk_obj = gtk_widget_get_accessible (sdd->button);
	atk_object_set_name (atk_obj, _("Show Desktop Button"));
        g_signal_connect (G_OBJECT (sdd->button), "button_press_event",
                          G_CALLBACK (do_not_eat_button_press), NULL);

        g_signal_connect (G_OBJECT (sdd->button), "toggled",
                          G_CALLBACK (button_toggled_callback), sdd);

        gtk_container_set_border_width (GTK_CONTAINER (sdd->button), 0);
        gtk_container_add (GTK_CONTAINER (sdd->button), sdd->image);
        gtk_container_add (GTK_CONTAINER (sdd->applet), sdd->button);

        g_signal_connect (G_OBJECT (sdd->button),
                          "size_allocate",
                          G_CALLBACK (button_size_allocated),
                          sdd);

        /* FIXME: Update this comment. */
        /* we have to bind change_orient before we do applet_widget_add
           since we need to get an initial change_orient signal to set our
           initial oriantation, and we get that during the _add call */
        g_signal_connect (G_OBJECT (sdd->applet),
                          "change_orient",
                          G_CALLBACK (applet_change_orient),
                          sdd);

	panel_applet_set_background_widget (PANEL_APPLET (sdd->applet),
					    GTK_WIDGET (sdd->applet));

        panel_applet_setup_menu_from_file (PANEL_APPLET (sdd->applet),
                                           NULL,
                                           "GNOME_ShowDesktopApplet.xml",
                                           NULL,
                                           show_desktop_menu_verbs,
                                           sdd);

        g_signal_connect (G_OBJECT (sdd->applet),
                          "destroy",
                          G_CALLBACK (applet_destroyed),
                          sdd);

	gtk_drag_dest_set (GTK_WIDGET(sdd->button), 0, NULL, 0, 0);

	g_signal_connect (G_OBJECT(sdd->button), "drag_motion",
			  G_CALLBACK (button_drag_motion),
			  sdd);
	g_signal_connect (G_OBJECT(sdd->button), "drag_leave",
			  G_CALLBACK (button_drag_leave),
			  sdd);

        popup_component = panel_applet_get_popup_component (sdd->applet);

        launchpad_integration_add_bonobo_ui(popup_component, "/popups/button3/LaunchpadItems");
        
  	gtk_widget_show_all (sdd->applet);

        return TRUE;
}
Example #21
0
static gboolean
workrave_applet_fill(PanelApplet *applet)
{
  GdkPixbuf *pixbuf = NULL;
  GtkWidget *hbox = NULL;
  BonoboUIComponent *ui = NULL;
  PanelAppletOrient orient;

  // Create menus.
  panel_applet_setup_menu_from_file(applet, WORKRAVE_UIDATADIR, "GNOME_WorkraveApplet.xml", NULL,
                                    workrave_applet_verbs, applet);

  // Add listeners for menu toggle-items.
  ui = panel_applet_get_popup_component(applet);
  bonobo_ui_component_add_listener(ui, "ShowLog", showlog_callback, NULL);
  bonobo_ui_component_add_listener(ui, "Normal", mode_callback, NULL);
  bonobo_ui_component_add_listener(ui, "Suspended", mode_callback, NULL);
  bonobo_ui_component_add_listener(ui, "Quiet", mode_callback, NULL);

  panel_applet_set_flags(PANEL_APPLET(applet),
                         PANEL_APPLET_EXPAND_MINOR);

  gtk_container_set_border_width(GTK_CONTAINER(applet), 0);
  panel_applet_set_background_widget(applet, GTK_WIDGET(applet));
  gtk_widget_set_events(GTK_WIDGET(applet),
                        gtk_widget_get_events(GTK_WIDGET(applet)) | GDK_BUTTON_PRESS_MASK);


  g_signal_connect(G_OBJECT(applet), "button_press_event", G_CALLBACK(button_pressed),
                   g_applet);

  // Socket.
  g_applet->socket = gtk_socket_new();
  gtk_container_set_border_width(GTK_CONTAINER(g_applet->socket), 0);

  // Image
  pixbuf = gdk_pixbuf_new_from_file(WORKRAVE_PKGDATADIR "/images/workrave-icon-medium.png", NULL);
  g_applet->image = gtk_image_new_from_pixbuf(pixbuf);

  // Signals.
  g_signal_connect(g_applet->socket, "plug_removed", G_CALLBACK(plug_removed), NULL);
  g_signal_connect(g_applet->socket, "plug_added", G_CALLBACK(plug_added), NULL);
  g_signal_connect(G_OBJECT(applet), "change_orient", G_CALLBACK(change_orient), NULL);

  // Container.
  hbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(applet), hbox);
  gtk_box_pack_end(GTK_BOX(hbox), g_applet->socket, TRUE, TRUE, 0);
  gtk_box_pack_end(GTK_BOX(hbox), g_applet->image, TRUE, TRUE, 0);

  gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);

  g_applet->socket_id = gtk_socket_get_id(GTK_SOCKET(g_applet->socket));
  g_applet->size = panel_applet_get_size(applet);

  orient = panel_applet_get_orient(applet);

  switch (orient)
    {
    case PANEL_APPLET_ORIENT_UP:
      g_applet->orientation = 0;
      break;
    case PANEL_APPLET_ORIENT_RIGHT:
      g_applet->orientation = 1;
      break;
    case PANEL_APPLET_ORIENT_DOWN:
      g_applet->orientation = 2;
      break;
    case PANEL_APPLET_ORIENT_LEFT:
      g_applet->orientation = 3;
      break;
    }

  force_no_focus_padding(GTK_WIDGET(applet));
  force_no_focus_padding(GTK_WIDGET(g_applet->socket));
  force_no_focus_padding(GTK_WIDGET(g_applet->image));
  force_no_focus_padding(GTK_WIDGET(hbox));

  g_signal_connect(G_OBJECT(applet), "destroy", G_CALLBACK(workrave_applet_destroy), NULL);
	g_signal_connect(G_OBJECT(hbox), "realize",   G_CALLBACK(workrave_applet_realize), NULL);
	g_signal_connect(G_OBJECT(hbox), "unrealize", G_CALLBACK(workrave_applet_unrealize), NULL);
  
  gtk_widget_show(GTK_WIDGET(g_applet->image));
  gtk_widget_show(GTK_WIDGET(g_applet->socket));
  gtk_widget_show(GTK_WIDGET(hbox));
  gtk_widget_show(GTK_WIDGET(applet));

  g_signal_connect(G_OBJECT(applet), "size-allocate", G_CALLBACK(size_allocate), NULL);
  g_signal_connect(G_OBJECT(applet), "change_background", G_CALLBACK(change_background), NULL);

  return TRUE;
}
gboolean
workspace_switcher_applet_fill (PanelApplet *applet)
{
	PagerData *pager;
	GError *error;
	gboolean display_names;
        BonoboUIComponent* popup_component;
	
	panel_applet_add_preferences (applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL);
	
	pager = g_new0 (PagerData, 1);

	pager->applet = GTK_WIDGET (applet);

	panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR);

	setup_gconf (pager);
	
	error = NULL;
	pager->n_rows = panel_applet_gconf_get_int (applet, "num_rows", &error);
	if (error) {
                g_printerr (_("Error loading num_rows value for Workspace Switcher: %s\n"),
                            error->message);
		g_error_free (error);
                /* leave current value */
	}

        pager->n_rows = CLAMP (pager->n_rows, 1, MAX_REASONABLE_ROWS);

	error = NULL;
	display_names = panel_applet_gconf_get_bool (applet, "display_workspace_names", &error);
	if (error) {
                g_printerr (_("Error loading display_workspace_names value for Workspace Switcher: %s\n"),
                            error->message);
		g_error_free (error);
                /* leave current value */
	}

	if (display_names) {
		pager->display_mode = WNCK_PAGER_DISPLAY_NAME;
	} else {
		pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT;
	}

	error = NULL;
	pager->display_all = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error);
	if (error) {
                g_printerr (_("Error loading display_all_workspaces value for Workspace Switcher: %s\n"),
                            error->message);
		g_error_free (error);
                /* leave current value */
	}
	
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		pager->orientation = GTK_ORIENTATION_VERTICAL;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
	default:
		pager->orientation = GTK_ORIENTATION_HORIZONTAL;
		break;
	}

	pager->screen = wncklet_get_screen (pager->applet);

	/* because the pager doesn't respond to signals at the moment */
	wnck_screen_force_update (pager->screen);

	pager->pager = wnck_pager_new (pager->screen);
	wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN);

	g_signal_connect (G_OBJECT (pager->pager), "destroy",
			  G_CALLBACK (destroy_pager),
			  pager);

	pager_update (pager);
	
	gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager);
	gtk_widget_show (pager->pager);

	gtk_widget_show (pager->applet);

	g_signal_connect (G_OBJECT (pager->applet),
			  "realize",
			  G_CALLBACK (applet_realized),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "change_orient",
			  G_CALLBACK (applet_change_orient),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "scroll-event",
			  G_CALLBACK (applet_scroll),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "change_background",
			  G_CALLBACK (applet_change_background),
			  pager);

	panel_applet_set_background_widget (PANEL_APPLET (pager->applet),
					    GTK_WIDGET (pager->applet));
	
	panel_applet_setup_menu_from_file (PANEL_APPLET (pager->applet),
					   NULL,
					   "GNOME_WorkspaceSwitcherApplet.xml",
					   NULL,
					   pager_menu_verbs,
					   pager);

	if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) {
		BonoboUIComponent *popup_component;

		popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet));

		bonobo_ui_component_set_prop (popup_component,
					      "/commands/PagerPreferences",
					      "hidden", "1",
					      NULL);
	}

        popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet));

        launchpad_integration_add_bonobo_ui(popup_component, "/popups/button3/LaunchpadItems");        


	return TRUE;
}
Example #23
0
static void
present_ap_popup (WirelessApplet *applet)
{
	GtkRequisition  req;
	GdkScreen      *screen;
	GdkRectangle    monitor;
	int             button_w, button_h;
	int             x, y;
	int             w, h;
	int             i, n;
	gboolean        found_monitor = FALSE;
	GtkWidget      *button = applet->button;
	GtkWidget      *window = applet->ap_popup;
	
	/* Get root origin of the toggle button, and position above that. */
	gdk_window_get_origin (button->window, &x, &y);

	gtk_window_get_size (GTK_WINDOW (window), &w, &h);
	gtk_widget_size_request (window, &req);
	w = req.width;
	h = req.height;

	button_w = button->allocation.width;
	button_h = button->allocation.height;

	screen = gtk_window_get_screen (GTK_WINDOW (window));

	n = gdk_screen_get_n_monitors (screen);
	for (i = 0; i < n; i++) {
		gdk_screen_get_monitor_geometry (screen, i, &monitor);
		if (x >= monitor.x && x <= monitor.x + monitor.width &&
		    y >= monitor.y && y <= monitor.y + monitor.height) {
			found_monitor = TRUE;
			break;
		}
	}

	if ( ! found_monitor) {
		/* eek, we should be on one of those xinerama
		   monitors */
		monitor.x = 0;
		monitor.y = 0;
		monitor.width = gdk_screen_get_width (screen);
		monitor.height = gdk_screen_get_height (screen);
	}
		
	/* Based on panel orientation, position the popup.
	 * Ignore window gravity since the window is undecorated.
	 * The orientations are all named backward from what
	 * I expected.
	 */
	switch (panel_applet_get_orient (PANEL_APPLET (applet))) {
	case PANEL_APPLET_ORIENT_RIGHT:
		x += button_w;
		if ((y + h) > monitor.y + monitor.height)
			y -= (y + h) - (monitor.y + monitor.height);
		break;
	case PANEL_APPLET_ORIENT_LEFT:
		x -= w;
		if ((y + h) > monitor.y + monitor.height)
			y -= (y + h) - (monitor.y + monitor.height);
		break;
	case PANEL_APPLET_ORIENT_DOWN:
		y += button_h;
		if ((x + w) > monitor.x + monitor.width)
			x -= (x + w) - (monitor.x + monitor.width);
		break;
	case PANEL_APPLET_ORIENT_UP:
		y -= h;
		if ((x + w) > monitor.x + monitor.width)
			x -= (x + w) - (monitor.x + monitor.width);
		break;
	}

	gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (applet->ap_view)));
		
	gtk_window_move (GTK_WINDOW (window), x, y);
	gtk_window_present (GTK_WINDOW (window));
	//gtk_widget_show (window);
}
Example #24
0
/* Do the actual applet initialization */
static void init_wtapplet (PanelApplet *applet) {
	WTApplet *wtapplet = g_new0 (WTApplet, 1);

	wtapplet->applet = applet;
	wtapplet->prefs = loadPreferences(wtapplet);
	wtapplet->activescreen = wnck_screen_get_default();
	wnck_screen_force_update(wtapplet->activescreen);
	wtapplet->activeworkspace = wnck_screen_get_active_workspace(wtapplet->activescreen);
	wtapplet->activewindow = wnck_screen_get_active_window(wtapplet->activescreen);
	wtapplet->umaxedwindow = getUpperMaximized(wtapplet);
	wtapplet->rootwindow = getRootWindow(wtapplet->activescreen);
	wtapplet->prefbuilder = gtk_builder_new();
	wtapplet->box = GTK_BOX(gtk_hbox_new(FALSE, 0));
	wtapplet->icon = GTK_IMAGE(gtk_image_new());
	wtapplet->title = GTK_LABEL(gtk_label_new(NULL));
	wtapplet->eb_icon = GTK_EVENT_BOX(gtk_event_box_new());
	wtapplet->eb_title = GTK_EVENT_BOX(gtk_event_box_new());
	wtapplet->orient = panel_applet_get_orient(wtapplet->applet);
	wtapplet->size_hints = g_new(gint,2);

	// Widgets to eventboxes, eventboxes to box
	gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->icon), TRUE);
	gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->title), TRUE);
	gtk_container_add (GTK_CONTAINER (wtapplet->eb_icon), GTK_WIDGET(wtapplet->icon));
	gtk_container_add (GTK_CONTAINER (wtapplet->eb_title), GTK_WIDGET(wtapplet->title));
	gtk_event_box_set_visible_window (wtapplet->eb_icon, FALSE);
	gtk_event_box_set_visible_window (wtapplet->eb_title, FALSE);

	// Rotate & place elements
	setAlignment(wtapplet, (gfloat)wtapplet->prefs->alignment);
	placeWidgets(wtapplet);

	// Add box to applet
	gtk_container_add (GTK_CONTAINER(wtapplet->applet), GTK_WIDGET(wtapplet->box));

	// Set event handling (icon & title clicks)
	g_signal_connect(G_OBJECT (wtapplet->eb_icon), "button-press-event", G_CALLBACK (icon_clicked), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->eb_title), "button-press-event", G_CALLBACK (title_clicked), wtapplet);
	
	// Global window tracking
	g_signal_connect(wtapplet->activescreen, "active-window-changed", G_CALLBACK (active_window_changed), wtapplet); // <-- this thing is crashing with compiz !!!
	g_signal_connect(wtapplet->activescreen, "viewports-changed", G_CALLBACK (viewports_changed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "active-workspace-changed", G_CALLBACK (active_workspace_changed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "window-closed", G_CALLBACK (window_closed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "window-opened", G_CALLBACK (window_opened), wtapplet);

	// g_signal_connect(G_OBJECT (wtapplet->title), "size-request", G_CALLBACK (applet_title_size_request), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "size-allocate", G_CALLBACK (applet_size_allocate), wtapplet);

	g_signal_connect(G_OBJECT (wtapplet->applet), "change-background", G_CALLBACK (applet_change_background), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "change-orient", G_CALLBACK (applet_change_orient), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "change-size", G_CALLBACK (applet_change_pixel_size), wtapplet);
	
	// Track active window changes
	wtapplet->active_handler_state = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "state-changed", G_CALLBACK (active_window_state_changed), wtapplet);
	wtapplet->active_handler_name = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "name-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet);
	wtapplet->active_handler_icon = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "icon-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet);

	
	// Setup applet right-click menu
	GtkActionGroup *action_group = gtk_action_group_new ("WindowButtons Applet Actions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group, windowtitle_menu_actions, G_N_ELEMENTS (windowtitle_menu_actions), wtapplet);
	panel_applet_setup_menu (applet, windowtitle_menu_items, action_group);
	panel_applet_set_background_widget (wtapplet->applet, GTK_WIDGET (wtapplet->applet)); // Automatic background update
	
	toggleExpand  (wtapplet);
	toggleHidden  (wtapplet);	// Properly hide or show stuff
	updateTitle   (wtapplet);
}
Example #25
0
void gweather_applet_create (GWeatherApplet *gw_applet)
{
    GSimpleActionGroup *action_group;
    GAction *action;
    gchar          *ui_path;
    AtkObject      *atk_obj;
    GWeatherForecastType type;
    GNetworkMonitor*monitor;

    panel_applet_set_flags (gw_applet->applet, PANEL_APPLET_EXPAND_MINOR);

    gw_applet->container = gtk_alignment_new (0.5, 0.5, 0, 0);
    gtk_container_add (GTK_CONTAINER (gw_applet->applet), gw_applet->container);

    g_signal_connect (G_OBJECT(gw_applet->applet), "change_orient",
                       G_CALLBACK(change_orient_cb), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "size_allocate",
                       G_CALLBACK(size_allocate_cb), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "destroy", 
                       G_CALLBACK (applet_destroy), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "button_press_event",
                       G_CALLBACK(clicked_cb), gw_applet);
    g_signal_connect (G_OBJECT(gw_applet->applet), "key_press_event",           
			G_CALLBACK(key_press_cb), gw_applet);
                     
    gtk_widget_set_tooltip_text (GTK_WIDGET(gw_applet->applet), _("GNOME Weather"));

    atk_obj = gtk_widget_get_accessible (GTK_WIDGET (gw_applet->applet));
    if (GTK_IS_ACCESSIBLE (atk_obj))
	   atk_object_set_name (atk_obj, _("GNOME Weather"));

    gw_applet->orient = panel_applet_get_orient (gw_applet->applet);

    action_group = g_simple_action_group_new ();
	g_action_map_add_action_entries (G_ACTION_MAP (action_group),
	                                 weather_applet_menu_actions,
	                                 G_N_ELEMENTS (weather_applet_menu_actions),
	                                 gw_applet);
    ui_path = g_build_filename (GWEATHER_MENU_UI_DIR, "gweather-applet-menu.xml", NULL);
    panel_applet_setup_menu_from_file (gw_applet->applet,
				       ui_path, action_group,
				       GETTEXT_PACKAGE);
    g_free (ui_path);

	gtk_widget_insert_action_group (GTK_WIDGET (gw_applet->applet), "gweather",
	                                G_ACTION_GROUP (action_group));

    action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
	g_object_bind_property (gw_applet->applet, "locked-down", action, "enabled",
				G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);

    g_object_unref (action_group);

    type = g_settings_get_boolean (gw_applet->applet_settings, "detailed") ?
                                   GWEATHER_FORECAST_ZONE : GWEATHER_FORECAST_STATE;

    gw_applet->gweather_info = gweather_info_new(NULL, type);
    g_signal_connect (gw_applet->gweather_info, "updated",
                      G_CALLBACK (update_finish), gw_applet);

    place_widgets(gw_applet);        

    monitor = g_network_monitor_get_default();
    g_signal_connect (monitor, "network-changed",
                      G_CALLBACK (network_changed), gw_applet);
}
Example #26
0
gboolean
mc_show_history (GtkWidget      *event_box, 
                         GdkEventButton *event,
		 MCData    *mc)
{
     GtkWidget *window;
     GtkWidget *scrolled_window;
     GtkListStore *store;
     GtkTreeIter iter;
     GtkTreeModel *model;
     GtkWidget    *treeview;
     GtkCellRenderer *cell_renderer;
     GtkTreeViewColumn *column;
     GtkRequisition  req;
     gchar *command_list[1];
     int i, j;
     gint win_x, win_y, width, height;
     gint entry_h, entry_x, entry_y, applet_x, applet_y;

     /* count commands stored in history list */
     for(i = 0, j = 0; i < MC_HISTORY_LIST_LENGTH; i++)
	 if(exists_history_entry(i))
	     j++;

     window = gtk_window_new(GTK_WINDOW_POPUP); 
     gtk_window_set_screen (GTK_WINDOW (window),
			    gtk_widget_get_screen (GTK_WIDGET (mc->applet)));
     gtk_window_set_policy(GTK_WINDOW(window), 0, 0, 1);
     gtk_widget_set_app_paintable (window, TRUE);
     gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_COMBO);
     /* cb */
     g_signal_connect_after(GTK_OBJECT(window),
			      "button_press_event",
			      GTK_SIGNAL_FUNC(history_popup_clicked_cb),
			      NULL);
     g_signal_connect_after (G_OBJECT (window), "key_press_event",
     		       G_CALLBACK (history_key_press_cb), NULL);

     gdk_window_get_geometry (GTK_WIDGET (mc->applet_box)->window, NULL, NULL,
         &width, &height, NULL);
     gdk_window_get_origin (mc->applet_box->window, &applet_x, &applet_y);
     gdk_window_get_position (mc->entry->window, &entry_x, &entry_y);
     gdk_drawable_get_size (mc->entry->window, NULL, &entry_h);

      win_x=applet_x + entry_x-1;
      win_y=applet_y + entry_y;

      /* size */
      gtk_widget_set_usize(GTK_WIDGET(window), width-2*(entry_x-1), 350);
     /* scrollbars */
     /* create scrolled window to put the Gtk_list widget inside */
     scrolled_window=gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
				    GTK_POLICY_AUTOMATIC,
				    GTK_POLICY_AUTOMATIC);
     g_signal_connect(GTK_OBJECT(scrolled_window),
			"button_release_event",
			GTK_SIGNAL_FUNC(history_popup_clicked_inside_cb),
			NULL);
     gtk_container_add(GTK_CONTAINER(window), scrolled_window);
     gtk_container_set_border_width (GTK_CONTAINER(scrolled_window), 1);
     gtk_widget_show(scrolled_window);
          
     store = gtk_list_store_new (1, G_TYPE_STRING);

     /* add history entries to list */
     if (j == 0) {
          gtk_list_store_append (store, &iter);
          gtk_list_store_set (store, &iter,0, _("No items in history"), -1);
     }
     else {	
          for(i = 0; i < MC_HISTORY_LIST_LENGTH; i++)
	      {
     	     if(exists_history_entry(i))
	     	 {
     		      command_list[0] = get_history_entry(i);
                      gtk_list_store_prepend (store, &iter);
                      gtk_list_store_set (store, &iter,0,command_list[0],-1);
		 }
	      }
     } 
     model = GTK_TREE_MODEL(store);
     treeview = gtk_tree_view_new_with_model (model);
     g_object_set_data (G_OBJECT (mc->applet), "tree", treeview);
     cell_renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (NULL, cell_renderer,
                                                       "text", 0, NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
     if (j == 0) {
          gtk_tree_selection_set_mode( (GtkTreeSelection *)gtk_tree_view_get_selection
                                (GTK_TREE_VIEW (treeview)),
                                 GTK_SELECTION_NONE);
     }
     else {
          gtk_tree_selection_set_mode( (GtkTreeSelection *)gtk_tree_view_get_selection
                                (GTK_TREE_VIEW (treeview)),
                                 GTK_SELECTION_SINGLE);
          g_signal_connect (G_OBJECT (treeview), "button_press_event",
     		       G_CALLBACK (history_list_button_press_cb), mc);
          g_signal_connect (G_OBJECT (treeview), "key_press_event",
     		       G_CALLBACK (history_list_key_press_cb), mc);
     }
   
     g_object_unref (G_OBJECT (model));
     gtk_container_add(GTK_CONTAINER(scrolled_window),treeview);
     gtk_widget_show (treeview); 
     
     gtk_widget_size_request (window, &req);

   
     switch (panel_applet_get_orient (mc->applet)) {
        case PANEL_APPLET_ORIENT_RIGHT:
        case PANEL_APPLET_ORIENT_LEFT:
     case PANEL_APPLET_ORIENT_DOWN:
            win_y += (entry_h+BORDER-1);
     	break;
        
     case PANEL_APPLET_ORIENT_UP:
            win_y -= (req.height+BORDER-1);
	break;
     }

     gtk_window_move (GTK_WINDOW (window), win_x, win_y);
     g_signal_connect ((gpointer) window, "expose_event",
                    G_CALLBACK (history_window_expose_event),
                    NULL);
     gtk_widget_show(window);

     /* grab focus */
     gdk_pointer_grab (window->window,
		       TRUE,
		       GDK_BUTTON_PRESS_MASK
		       | GDK_BUTTON_RELEASE_MASK
		       | GDK_ENTER_NOTIFY_MASK
		       | GDK_LEAVE_NOTIFY_MASK 
		       | GDK_POINTER_MOTION_MASK,
		       NULL,
		       NULL,
		       GDK_CURRENT_TIME); 
     gdk_keyboard_grab (window->window, TRUE, GDK_CURRENT_TIME);
     gtk_grab_add(window);
     gtk_widget_grab_focus (treeview);
 
     return FALSE;
}
Example #27
0
LoadGraph *
load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
		guint id, guint speed, guint size, gboolean visible, 
		const gchar *name, LoadGraphDataFunc get_data)
{
    LoadGraph *g;
    PanelAppletOrient orient;
    
    g = g_new0 (LoadGraph, 1);
    g->netspeed_in = netspeed_new(g);
    g->netspeed_out = netspeed_new(g);
    g->visible = visible;
    g->name = name;
    g->n = n;
    g->id = id;
    g->speed  = MAX (speed, 50);
    g->size   = MAX (size, 10);
    g->pixel_size = panel_applet_get_size (ma->applet);
    g->tooltip_update = FALSE;
    g->show_frame = TRUE;
    g->multiload = ma;
		
    g->main_widget = gtk_vbox_new (FALSE, 0);

    g->box = gtk_vbox_new (FALSE, 0);
    
    orient = panel_applet_get_orient (g->multiload->applet);
    switch (orient)
    {
    case PANEL_APPLET_ORIENT_UP:
    case PANEL_APPLET_ORIENT_DOWN:
    {
	g->orient = FALSE;
	break;
    }
    case PANEL_APPLET_ORIENT_LEFT:
    case PANEL_APPLET_ORIENT_RIGHT:
    {
	g->orient = TRUE;
	break;
    }
    default:
	g_assert_not_reached ();
    }
    
    if (g->show_frame)
    {
	g->frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (g->frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (g->frame), g->box);
	gtk_box_pack_start (GTK_BOX (g->main_widget), g->frame, TRUE, TRUE, 0);
    }
    else
    {
	g->frame = NULL;
	gtk_box_pack_start (GTK_BOX (g->main_widget), g->box, TRUE, TRUE, 0);
    }

    load_graph_load_config (g);

    g->get_data = get_data;

    g->timer_index = -1;

    if (g->orient)
    	gtk_widget_set_size_request (g->main_widget, -1, g->size);
    else
        gtk_widget_set_size_request (g->main_widget, g->size, -1);

    g->disp = gtk_drawing_area_new ();
    gtk_widget_set_events (g->disp, GDK_EXPOSURE_MASK |
				    GDK_ENTER_NOTIFY_MASK |
    				    GDK_LEAVE_NOTIFY_MASK |
				    GDK_BUTTON_PRESS_MASK);
	
    g_signal_connect (G_OBJECT (g->disp), "expose_event",
			G_CALLBACK (load_graph_expose), g);
    g_signal_connect (G_OBJECT(g->disp), "configure_event",
			G_CALLBACK (load_graph_configure), g);
    g_signal_connect (G_OBJECT(g->disp), "destroy",
			G_CALLBACK (load_graph_destroy), g);
    g_signal_connect (G_OBJECT(g->disp), "button-press-event",
		        G_CALLBACK (load_graph_clicked), g);
    g_signal_connect (G_OBJECT(g->disp), "enter-notify-event",
                      G_CALLBACK(load_graph_enter_cb), g);
    g_signal_connect (G_OBJECT(g->disp), "leave-notify-event",
                      G_CALLBACK(load_graph_leave_cb), g);
	
    gtk_box_pack_start (GTK_BOX (g->box), g->disp, TRUE, TRUE, 0);    
    gtk_widget_show_all(g->box);

    return g;
}
gboolean
workspace_switcher_applet_fill (PanelApplet *applet)
{
	PagerData *pager;
        GtkActionGroup *action_group;
	GtkAction *action;
	gboolean display_names;
	
	panel_applet_add_preferences (applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL);
	
	pager = g_new0 (PagerData, 1);

	pager->applet = GTK_WIDGET (applet);

	panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR);

	setup_gconf (pager);
	
	pager->n_rows = g_settings_get_int (pager->settings, "num-rows");

	display_names = g_settings_get_boolean (pager->settings, "display-workspace-names");

	if (display_names) {
		pager->display_mode = WNCK_PAGER_DISPLAY_NAME;
	} else {
		pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT;
	}

	pager->display_all = g_settings_get_boolean (pager->settings, "display-all-workspaces");
	
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		pager->orientation = GTK_ORIENTATION_VERTICAL;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
	default:
		pager->orientation = GTK_ORIENTATION_HORIZONTAL;
		break;
	}

	pager->pager = wnck_pager_new ();
	pager->screen = NULL;
	pager->wm = PAGER_WM_UNKNOWN;
	wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN);

	g_signal_connect (G_OBJECT (pager->pager), "destroy",
			  G_CALLBACK (destroy_pager),
			  pager);
	
	gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager);
	gtk_widget_show (pager->pager);

	g_signal_connect (G_OBJECT (pager->applet),
			  "realize",
			  G_CALLBACK (applet_realized),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "unrealize",
			  G_CALLBACK (applet_unrealized),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "change_orient",
			  G_CALLBACK (applet_change_orient),
			  pager);
	g_signal_connect (G_OBJECT (pager->applet),
			  "change_background",
			  G_CALLBACK (applet_change_background),
			  pager);

	gtk_widget_show (pager->applet);

	panel_applet_set_background_widget (PANEL_APPLET (pager->applet),
					    GTK_WIDGET (pager->applet));

        action_group = gtk_action_group_new ("WorkspaceSwitcher Applet Actions");
        gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
        gtk_action_group_add_actions (action_group,
                                      pager_menu_actions,
                                      G_N_ELEMENTS (pager_menu_actions),
                                      pager);
	panel_applet_setup_menu_from_resource (PANEL_APPLET (pager->applet),
					       WNCKLET_RESOURCE_PATH "workspace-switcher-menu.xml",
					       action_group);

	action = gtk_action_group_get_action (action_group, "PagerPreferences");
	g_object_bind_property (pager->applet, "locked-down",
				action, "visible",
				G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);

        g_object_unref (action_group);

	return TRUE;
}
/* Create a Sticky Notes applet */
StickyNotesApplet * stickynotes_applet_new(PanelApplet *panel_applet)
{
	AtkObject *atk_obj;
	gchar *ui_path;

	/* Create Sticky Notes Applet */
	StickyNotesApplet *applet = g_new(StickyNotesApplet, 1);

	/* Initialize Sticky Notes Applet */
	applet->w_applet = GTK_WIDGET(panel_applet);
	applet->w_image = gtk_image_new();
	applet->destroy_all_dialog = NULL;
	applet->prelighted = FALSE;
	applet->pressed = FALSE;

	applet->menu_tip = NULL;

	/* Expand the applet for Fitts' law complience. */
	panel_applet_set_flags(panel_applet, PANEL_APPLET_EXPAND_MINOR);

	/* Add the applet icon */
	gtk_container_add(GTK_CONTAINER(panel_applet), applet->w_image);
	applet->panel_size = panel_applet_get_size (panel_applet);
	applet->panel_orient = panel_applet_get_orient (panel_applet);
	stickynotes_applet_update_icon(applet);

	/* Add the popup menu */
	applet->action_group = gtk_action_group_new ("StickyNotes Applet Actions");
	gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (applet->action_group,
				      stickynotes_applet_menu_actions,
				      G_N_ELEMENTS (stickynotes_applet_menu_actions),
				      applet);
	gtk_action_group_add_toggle_actions (applet->action_group,
					     stickynotes_applet_menu_toggle_actions,
					     G_N_ELEMENTS (stickynotes_applet_menu_toggle_actions),
					     applet);
	ui_path = g_build_filename (STICKYNOTES_MENU_UI_DIR, "stickynotes-applet-menu.xml", NULL);
	panel_applet_setup_menu_from_file(panel_applet, ui_path, applet->action_group);
	g_free (ui_path);

	if (panel_applet_get_locked_down (panel_applet)) {
		GtkAction *action;

		action = gtk_action_group_get_action (applet->action_group, "preferences");
		gtk_action_set_visible (action, FALSE);
	}

	/* Connect all signals for applet management */
	g_signal_connect(G_OBJECT(applet->w_applet), "button-press-event",
			G_CALLBACK(applet_button_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "key-press-event",
			G_CALLBACK(applet_key_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "focus-in-event",
			G_CALLBACK(applet_focus_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "focus-out-event",
			G_CALLBACK(applet_focus_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "enter-notify-event",
			G_CALLBACK(applet_cross_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "leave-notify-event",
			G_CALLBACK(applet_cross_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "size-allocate",
			G_CALLBACK(applet_size_allocate_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "change-orient",
			G_CALLBACK(applet_change_orient_cb), applet);
	g_signal_connect(G_OBJECT(applet->w_applet), "destroy",
			G_CALLBACK(applet_destroy_cb), applet);

        panel_applet_set_background_widget (panel_applet, applet->w_applet);

	atk_obj = gtk_widget_get_accessible (applet->w_applet);
	atk_object_set_name (atk_obj, _("Sticky Notes"));

	/* Show the applet */
	gtk_widget_show_all(GTK_WIDGET(applet->w_applet));

	return applet;
}