Ejemplo n.º 1
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);
}
Ejemplo n.º 2
0
static void
setup_gconf (TasklistData *tasklist)
{
	GConfClient *client;
	char *key;

	client = gconf_client_get_default ();

	key = panel_applet_gconf_get_full_key (PANEL_APPLET (tasklist->applet),
					       "display_all_workspaces");
	tasklist->listeners[0] = gconf_client_notify_add(client, key,
				(GConfClientNotifyFunc)display_all_workspaces_changed,
				tasklist,
				NULL, NULL);
	g_free (key);

	key = panel_applet_gconf_get_full_key (PANEL_APPLET (tasklist->applet),
					       "group_windows");
	tasklist->listeners[1] = gconf_client_notify_add(client, key,
				(GConfClientNotifyFunc)group_windows_changed,
				tasklist,
				NULL, NULL);
	g_free (key);

	key = panel_applet_gconf_get_full_key (PANEL_APPLET (tasklist->applet),
					       "move_unminimized_windows");
	tasklist->listeners[2] = gconf_client_notify_add(client, key,
				(GConfClientNotifyFunc)move_unminimized_windows_changed,
				tasklist,
				NULL, NULL);
	g_free (key);

	g_object_unref (G_OBJECT (client));
}
Ejemplo n.º 3
0
static void
wireless_applet_save_properties (WirelessApplet *applet)
{
	if (applet->device)
		panel_applet_gconf_set_string (PANEL_APPLET (applet),
			"device", applet->device, NULL);
	panel_applet_gconf_set_bool (PANEL_APPLET (applet),
			"percent", applet->show_percent, NULL);
}
Ejemplo n.º 4
0
static GtkWidget *
wireless_applet_new (WirelessApplet *applet)
{
	panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);

	applet->skfd = iw_sockets_open ();
	
	/* this ensures that properties are loaded */
	wireless_applet_load_properties (applet);
	wireless_applet_load_theme (applet);

	setup_widgets (applet);

	applet->tips = gtk_tooltips_new ();
	g_object_ref (applet->tips);
	gtk_object_sink (GTK_OBJECT (applet->tips));
	applet->prefs = NULL;

	g_signal_connect (applet,"destroy",
			  G_CALLBACK (wireless_applet_destroy),NULL);

	g_signal_connect (applet->button, "button_press_event",
			  G_CALLBACK (do_not_eat_button_press), NULL);
	
	/* Setup the menus */
	panel_applet_setup_menu_from_file (PANEL_APPLET (applet),
			NULL,
			"GNOME_WirelessApplet.xml",
			NULL,
			wireless_menu_verbs,
			applet);

	if (panel_applet_get_locked_down (PANEL_APPLET (applet))) {
		BonoboUIComponent *popup_component;

		popup_component = panel_applet_get_popup_component (PANEL_APPLET (applet));

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

	check_wireless (applet);
	wireless_applet_timeout_handler (applet);

	
	wireless_applet_start_timeout (applet);
		 
	g_signal_connect (G_OBJECT (applet), "change_size",
			  G_CALLBACK (change_size_cb), applet);
	g_signal_connect (G_OBJECT (applet), "change_orient",
			  G_CALLBACK (change_orient_cb), applet);
  
	return GTK_WIDGET (applet);
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
static void
trash_applet_init (TrashApplet *applet)
{
  const GtkTargetEntry drop_types[] = { { "text/uri-list" } };

  /* needed to clamp ourselves to the panel size */
  panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);

  /* setup the image */
  applet->image = g_object_ref_sink (gtk_image_new ());
  gtk_container_add (GTK_CONTAINER (applet),
                     GTK_WIDGET (applet->image));
  gtk_widget_show (GTK_WIDGET (applet->image));

  /* setup the trash backend */
  applet->trash = g_file_new_for_uri ("trash:/");
  applet->trash_monitor = g_file_monitor_file (applet->trash, 0, NULL, NULL);
  g_signal_connect_swapped (applet->trash_monitor, "changed",
                            G_CALLBACK (trash_applet_monitor_changed),
                            applet);

  /* setup drag and drop */
  gtk_drag_dest_set (GTK_WIDGET (applet), GTK_DEST_DEFAULT_ALL,
                     drop_types, G_N_ELEMENTS (drop_types),
                     GDK_ACTION_MOVE);

  /* synthesise the first update */
  applet->items = -1;
  trash_applet_monitor_changed (applet);
}
Ejemplo n.º 7
0
/**
 * gpm_applet_cb:
 * @_applet: GpmInhibitApplet instance created by the applet factory
 * @iid: Applet id
 *
 * the function called by libpanel-applet factory after creation
 **/
static gboolean
gpm_applet_cb (PanelApplet *_applet, const gchar *iid, gpointer data)
{
	GpmInhibitApplet *applet = GPM_INHIBIT_APPLET(_applet);
	GSimpleActionGroup *action_group;
	gchar *ui_path;

	static const GActionEntry menu_actions [] = {
		{ "about", gpm_applet_dialog_about_cb, NULL, NULL, NULL },
	};

	if (strcmp (iid, GPM_INHIBIT_APPLET_ID) != 0) {
		return FALSE;
	}

	action_group = g_simple_action_group_new ();
	g_action_map_add_action_entries (G_ACTION_MAP (action_group),
					 menu_actions,
					 G_N_ELEMENTS (menu_actions),
					 applet);
	ui_path = g_build_filename (INHIBIT_MENU_UI_DIR, "inhibit-applet-menu.xml", NULL);
	panel_applet_setup_menu_from_file (PANEL_APPLET (applet), ui_path, action_group, GETTEXT_PACKAGE);
	g_free (ui_path);

	gtk_widget_insert_action_group (GTK_WIDGET (applet), "inhibit",
					G_ACTION_GROUP (action_group));

	g_object_unref (action_group);

	return TRUE;
}
Ejemplo n.º 8
0
static gboolean
workrave_applet_set_menu_status(WorkraveApplet *applet, const char *name,
                                gboolean status, GError **err)
{
  BonoboUIComponent *ui = NULL;
  gboolean set = FALSE;

  if (applet != NULL && applet->applet != NULL)
    {
      ui = panel_applet_get_popup_component(PANEL_APPLET(applet->applet));
    }

  if (ui != NULL)
    {
      const char *s = bonobo_ui_component_get_prop(ui, name, "state", NULL);

      set = (s != NULL && atoi(s) != 0);

      if ((status && !set) || (!status && set))
        {
          bonobo_ui_component_set_prop(ui, name, "state", status ? "1" : "0", NULL);
        }
    }

  return TRUE;
}
Ejemplo n.º 9
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);
}
static void
all_workspaces_toggled (GtkToggleButton *button,
			PagerData       *pager)
{
	panel_applet_gconf_set_bool (PANEL_APPLET (pager->applet),
				     "display_all_workspaces",
				     gtk_toggle_button_get_active (button),
				     NULL);
}
Ejemplo n.º 11
0
static void
move_minimized_toggled (GtkToggleButton *button,
			TasklistData    *tasklist)
{
	panel_applet_gconf_set_bool (PANEL_APPLET (tasklist->applet),
				     "move_unminimized_windows",
				     gtk_toggle_button_get_active (button),
				     NULL);
}
Ejemplo n.º 12
0
static void
wireless_applet_load_properties (WirelessApplet *applet)
{
	wireless_applet_set_device (applet,
			  panel_applet_gconf_get_string (PANEL_APPLET (applet),
							 "device", NULL));

	/* Oooh, new applet, let's put in the defaults */
	if (applet->device == NULL)
	{
		applet->device = g_strdup (CFG_DEVICE);
		applet->show_percent = TRUE;
		return;
	}

	applet->show_percent = panel_applet_gconf_get_bool
		(PANEL_APPLET (applet), "percent", NULL);
}
static void
num_rows_value_changed (GtkSpinButton *button,
			PagerData       *pager)
{
	panel_applet_gconf_set_int (PANEL_APPLET (pager->applet),
				    "num_rows",
				    gtk_spin_button_get_value_as_int (button),
				    NULL);
}
Ejemplo n.º 14
0
static void
display_all_workspaces_toggled (GtkToggleButton *button,
				TasklistData    *tasklist)
{
	panel_applet_gconf_set_bool (PANEL_APPLET (tasklist->applet),
				     "display_all_workspaces",
				     gtk_toggle_button_get_active (button),
				     NULL);
}
Ejemplo n.º 15
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;
}
Ejemplo n.º 16
0
static void
group_windows_toggled (GtkToggleButton *button,
		       TasklistData    *tasklist)
{
	if (gtk_toggle_button_get_active (button)) {
		char *str;
		str = g_object_get_data (G_OBJECT (button), "group_value");
		panel_applet_gconf_set_string (PANEL_APPLET (tasklist->applet),
					       "group_windows", str,
					       NULL);
	}
}
Ejemplo n.º 17
0
static void
panel_applet_constructed (GObject *object)
{
	PanelApplet *applet = PANEL_APPLET (object);

	if (!applet->priv->closure || !applet->priv->id) {
		g_printerr ("Bad use of PanelApplet API: you should not create a PanelApplet object yourself. Please use panel_applet_factory_main() instead.\n");
		g_assert_not_reached ();
	}

	panel_applet_setup (applet);
}
static void
setup_gconf (PagerData *pager)
{
	GConfClient *client;
	char *key;

	client = gconf_client_get_default ();

	key = panel_applet_gconf_get_full_key (PANEL_APPLET (pager->applet),
					       "num_rows");
	pager->listeners[0] = gconf_client_notify_add(client, key,
				(GConfClientNotifyFunc)num_rows_changed,
				pager,
				NULL, NULL);
		
	g_free (key);


	key = panel_applet_gconf_get_full_key (PANEL_APPLET (pager->applet),
					       "display_workspace_names");
	pager->listeners[1] = gconf_client_notify_add(client, key,
				(GConfClientNotifyFunc)display_workspace_names_changed,
				pager,
				NULL, NULL);
		
	g_free (key);

	key = panel_applet_gconf_get_full_key (PANEL_APPLET (pager->applet),
					       "display_all_workspaces");
	pager->listeners[2] = gconf_client_notify_add(client, key,
				(GConfClientNotifyFunc)all_workspaces_changed,
				pager,
				NULL, NULL);
		
	g_free (key);

	g_object_unref (G_OBJECT (client));

}
Ejemplo n.º 19
0
/* called when maximum width spin button is changed
 * check if we drop below min width
 * saves numeric GConf preference values
 */
static void
spin_maximum_size_changed (GtkSpinButton *button, TasklistData *tasklist)
{
	GtkSpinButton *min_b = GTK_SPIN_BUTTON (tasklist->minimum_size_spin);
	PanelApplet *applet = PANEL_APPLET (tasklist->applet);
	gint prop_value = gtk_spin_button_get_value (button);
	gint min_size = gtk_spin_button_get_value (min_b);

	/* check if we drop below min width */
	if (prop_value < min_size)
		panel_applet_gconf_set_int (applet, "minimum_size", 
					    prop_value, NULL);
	panel_applet_gconf_set_int (applet, "maximum_size", prop_value, NULL);
}
Ejemplo n.º 20
0
static void
setup_gconf (PagerData *pager)
{
	pager->settings =
	  panel_applet_settings_new (PANEL_APPLET (pager->applet),
				     "org.consort.consort-panel.applet.workspace-switcher");

	g_signal_connect (pager->settings, "changed::num-rows",
			  G_CALLBACK (num_rows_changed), pager);
	g_signal_connect (pager->settings, "changed::display-workspace-names",
			  G_CALLBACK (display_workspace_names_changed), pager);
	g_signal_connect (pager->settings, "changed::display-all-workspaces",
			  G_CALLBACK (all_workspaces_changed), pager);
}
Ejemplo n.º 21
0
static void
applet_size_allocate (GtkWidget      *widget,
                      GtkAllocation  *allocation,
                      TasklistData   *tasklist)
{
	int len;
	const int *size_hints;

	size_hints = wnck_tasklist_get_size_hint_list (WNCK_TASKLIST (tasklist->tasklist), &len);
	g_assert (len % 2 == 0);

        panel_applet_set_size_hints (PANEL_APPLET (tasklist->applet),
		                     size_hints, len, 0);
}
Ejemplo n.º 22
0
static void
fish_applet_instance_init (FishApplet      *fish,
			   FishAppletClass *klass)
{
	fish->settings          = NULL;
	fish->lockdown_settings = NULL;

	fish->name     = NULL;
	fish->image    = NULL;
	fish->command  = NULL;
	fish->n_frames = 1;
	fish->speed    = 0.0;
	fish->rotate   = FALSE;

	fish->orientation = PANEL_APPLET_ORIENT_UP;

	fish->frame         = NULL;
	fish->drawing_area  = NULL;
	fish->surface       = NULL;
	fish->timeout       = 0;
	fish->current_frame = 0;
	fish->in_applet     = FALSE;

	fish->requisition.width  = -1;
	fish->requisition.height = -1;

	fish->prev_allocation.x      = -1;
	fish->prev_allocation.y      = -1;
	fish->prev_allocation.width  = -1;
	fish->prev_allocation.height = -1;

	fish->pixbuf = NULL;

	fish->preferences_dialog = NULL;

	fish->fortune_dialog = NULL;
	fish->fortune_view   = NULL;
	fish->fortune_label  = NULL;
	fish->fortune_cmd_label = NULL;
	fish->fortune_buffer = NULL;

	fish->source_id  = 0;
	fish->io_channel = NULL;

	fish->april_fools = FALSE;

	panel_applet_set_flags (PANEL_APPLET (fish),
				PANEL_APPLET_EXPAND_MINOR);
}
Ejemplo n.º 23
0
static void
applet_size_request (GtkWidget      *widget,
		     GtkRequisition *requisition,
		     TasklistData   *tasklist)
{
	int len;
	const int *size_hints;
	GtkRequisition child_req;
	int i;
	int maximum_size;
	int *new_size_hints;
	int new_len = 0;
    	WnckTasklist *wncktl = WNCK_TASKLIST (tasklist->tasklist);
	gint minimum_size = 0;
	
	
	if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL)
		minimum_size = wnck_tasklist_get_minimum_width (wncktl);
	else
		minimum_size = wnck_tasklist_get_minimum_height (wncktl);
	
	gtk_widget_get_child_requisition (tasklist->applet, &child_req);
	
	size_hints = wnck_tasklist_get_size_hint_list (wncktl, &len);
	new_size_hints = g_new0 (int, len);
	
	/* size_hints is an array of (max, min) int pairs
	 * where min(i) > max (i+1)
	 * convert it to clipped values
	 */
	maximum_size = tasklist->maximum_size - minimum_size;
	g_assert (maximum_size >= 0);

	for (i = 0; i < len; i += 2) {
		if (size_hints[i + 1] <= maximum_size) {
		        /* this one should be stored */
			if (size_hints[i] > maximum_size)
			    	new_size_hints[new_len] = maximum_size;
			else
				new_size_hints[new_len] = size_hints[i];
			new_size_hints[new_len + 1] = size_hints[i + 1];
			new_len += 2;
		}
	}
        panel_applet_set_size_hints (PANEL_APPLET (tasklist->applet),
		                     new_size_hints, 
				     new_len, child_req.width - 1);
	g_free (new_size_hints);
}
Ejemplo n.º 24
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;
}
Ejemplo n.º 25
0
static void
megaphone_applet_preferences_response_cb (GtkWidget       *dialog,
					  gint             response,
					  MegaphoneApplet *applet) 
{
	if (response == GTK_RESPONSE_ACCEPT) {
		EmpathyContactListView *contact_list;
		EmpathyContact         *contact;

		/* Retrieve the selected contact, if any and set it up in gconf.
		 * GConf will notify us from the change and we will adjust ourselves */
		contact_list = g_object_get_data (G_OBJECT (dialog), "contact-list");
		contact = empathy_contact_list_view_dup_selected (contact_list);
		if (contact) {
			EmpathyAccount   *account;
			const gchar *account_id;
			const gchar *contact_id;
			gchar       *str;

			account = empathy_contact_get_account (contact);
			account_id = empathy_account_get_unique_name (account);
			contact_id = empathy_contact_get_id (contact);

			str = g_strconcat (account_id, "/", contact_id, NULL);
			panel_applet_gconf_set_string (PANEL_APPLET (applet),
						       "avatar_token", "",
						       NULL);
			panel_applet_gconf_set_string (PANEL_APPLET (applet),
						       "contact_id", str,
						       NULL);
			g_free (str);
			g_object_unref (contact);
		}
	}
	gtk_widget_destroy (dialog);
}
static void
setup_sensitivity (PagerData *pager,
		   GladeXML *xml,
		   const char *wid1,
		   const char *wid2,
		   const char *wid3,
		   const char *key)
{
	PanelApplet *applet = PANEL_APPLET (pager->applet);
	GConfClient *client = gconf_client_get_default ();
	char *fullkey;
	GtkWidget *w;

	if (key[0] == '/')
		fullkey = g_strdup (key);
	else
		fullkey = panel_applet_gconf_get_full_key (applet, key);

	if (gconf_client_key_is_writable (client, fullkey, NULL)) {
		g_object_unref (G_OBJECT (client));
		g_free (fullkey);
		return;
	}
	g_object_unref (G_OBJECT (client));
	g_free (fullkey);

	w = glade_xml_get_widget (xml, wid1);
	g_assert (w != NULL);
	g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE,
			   GINT_TO_POINTER (1));
	gtk_widget_set_sensitive (w, FALSE);

	if (wid2 != NULL) {
		w = glade_xml_get_widget (xml, wid2);
		g_assert (w != NULL);
		g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE,
				   GINT_TO_POINTER (1));
		gtk_widget_set_sensitive (w, FALSE);
	}
	if (wid3 != NULL) {
		w = glade_xml_get_widget (xml, wid3);
		g_assert (w != NULL);
		g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE,
				   GINT_TO_POINTER (1));
		gtk_widget_set_sensitive (w, FALSE);
	}

}
Ejemplo n.º 27
0
static void
setup_gconf (TasklistData *tasklist)
{
        tasklist->settings =
          panel_applet_settings_new (PANEL_APPLET (tasklist->applet),
                                     "org.gnome.gnome-panel.applet.window-list");

        g_signal_connect (tasklist->settings, "changed::display-all-workspaces",
                          G_CALLBACK (display_all_workspaces_changed), tasklist);

        g_signal_connect (tasklist->settings, "changed::group-windows",
                          G_CALLBACK (group_windows_changed), tasklist);

        g_signal_connect (tasklist->settings, "changed::move-unminimized-windows",
                          G_CALLBACK (move_unminimized_windows_changed), tasklist);
}
Ejemplo n.º 28
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;
}
Ejemplo n.º 29
0
static void
panel_applet_set_property (GObject      *object,
			   guint         prop_id,
			   const GValue *value,
			   GParamSpec   *pspec)
{
	PanelApplet *applet = PANEL_APPLET (object);

	switch (prop_id) {
	case PROP_ID:
		applet->priv->id = g_value_dup_string (value);
		break;
	case PROP_CLOSURE:
		applet->priv->closure = g_value_get_pointer (value);
		/* We know closure should not be NULL, but we'll fail in
		 * panel_applet_constructed() with a proper message if this is
		 * the case. */
		if (applet->priv->closure)
			g_closure_set_marshal (applet->priv->closure,
					       panel_applet_marshal_BOOLEAN__STRING);
		break;
	case PROP_SETTINGS_PATH:
		panel_applet_set_settings_path (applet, g_value_get_string (value));
		break;
	case PROP_ORIENT:
		panel_applet_set_orient (applet, g_value_get_uint (value));
		break;
	case PROP_FLAGS:
		panel_applet_set_flags (applet, g_value_get_uint (value));
		break;
	case PROP_SIZE_HINTS: {
		const int *size_hints;
		gsize      n_elements;

		size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
							&n_elements, sizeof (gint32));
		panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
	}
		break;
	case PROP_LOCKED_DOWN:
		panel_applet_set_locked_down (applet, g_value_get_boolean (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
	}
}
Ejemplo n.º 30
0
static void
panel_applet_get_property (GObject    *object,
			   guint       prop_id,
			   GValue     *value,
			   GParamSpec *pspec)
{
	PanelApplet *applet = PANEL_APPLET (object);

	switch (prop_id) {
	case PROP_ID:
		g_value_set_string (value, applet->priv->id);
		break;
	case PROP_CLOSURE:
		g_value_set_pointer (value, applet->priv->closure);
		break;
	case PROP_SETTINGS_PATH:
		g_value_set_string (value, applet->priv->settings_path);
		break;
	case PROP_ORIENT:
		g_value_set_uint (value, applet->priv->orient);
		break;
	case PROP_FLAGS:
		g_value_set_uint (value, applet->priv->flags);
		break;
	case PROP_SIZE_HINTS: {
		GVariant **children;
		GVariant  *variant;
		gint       i;

		children = g_new (GVariant *, applet->priv->size_hints_len);
		for (i = 0; i < applet->priv->size_hints_len; i++)
			children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
		variant = g_variant_new_array (G_VARIANT_TYPE_INT32,
					       children, applet->priv->size_hints_len);
		g_free (children);
		g_value_set_pointer (value, variant);
	}
		break;
	case PROP_LOCKED_DOWN:
		g_value_set_boolean (value, applet->priv->locked_down);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
	}
}