Esempio n. 1
0
/**
 * panel_applet_get_orient:
 * @applet: a #PanelApplet.
 *
 * Gets the #PanelAppletOrient of @applet.
 *
 * Returns: the #PanelAppletOrient of @applet.
 **/
PanelAppletOrient
panel_applet_get_orient (PanelApplet *applet)
{
	g_return_val_if_fail (PANEL_IS_APPLET (applet), 0);

	return applet->priv->orient;
}
Esempio n. 2
0
/**
 * panel_applet_get_locked_down:
 * @applet: a #PanelApplet.
 *
 * Gets whether the panel @applet is on is locked down or not. A locked down
 * applet should not allow any change to its configuration.
 *
 * Returns: %TRUE if the panel @applet is on is locked down, %FALSE otherwise.
 **/
gboolean
panel_applet_get_locked_down (PanelApplet *applet)
{
	g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);

	return applet->priv->locked_down;
}
Esempio n. 3
0
/**
 * panel_applet_get_flags:
 * @applet: a #PanelApplet.
 *
 * Gets the #PanelAppletFlags of @applet.
 *
 * Returns: the #PanelAppletFlags of @applet.
 **/
PanelAppletFlags
panel_applet_get_flags (PanelApplet *applet)
{
	g_return_val_if_fail (PANEL_IS_APPLET (applet), PANEL_APPLET_FLAGS_NONE);

	return applet->priv->flags;
}
GSList *
mate_panel_applet_mateconf_get_list (MatePanelApplet     *applet,
			     const gchar     *key,
			     MateConfValueType   list_type,
			     GError         **opt_error)
{
	MateConfClient  *client;
	gchar        *full_key;
	GSList       *retval;
	GError      **error = NULL;
	GError       *our_error = NULL;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);

	if (opt_error)
		error = opt_error;
	else
		error = &our_error;

	full_key = mate_panel_applet_mateconf_get_full_key (applet, key);

	client = mate_panel_applet_mateconf_get_client ();

	retval = mateconf_client_get_list (client, full_key, list_type, error);

	g_free (full_key);

	if (!opt_error && our_error) {
		g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message);
		g_error_free (our_error);
	}

	return retval;
}
void
mate_panel_applet_mateconf_set_int (MatePanelApplet  *applet,
			    const gchar  *key,
			    gint          the_int,
			    GError      **opt_error)
{
	MateConfClient  *client;
	gchar        *full_key;
	GError      **error = NULL;
	GError       *our_error = NULL;

	g_return_if_fail (PANEL_IS_APPLET (applet));

	if (opt_error)
		error = opt_error;
	else
		error = &our_error;

	full_key = mate_panel_applet_mateconf_get_full_key (applet, key);

	client = mate_panel_applet_mateconf_get_client ();

	mateconf_client_set_int (client, full_key, the_int, error);

	g_free (full_key);

	if (!opt_error && our_error) {
		g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message);
		g_error_free (our_error);
	}
}
Esempio n. 6
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);
}
Esempio n. 7
0
/* Applets cannot set the lockdown state, so API is not public. */
static void
panel_applet_set_locked_down (PanelApplet *applet,
                              gboolean     locked_down)
{
	g_return_if_fail (PANEL_IS_APPLET (applet));

	if (applet->priv->locked_down == locked_down)
		return;

	applet->priv->locked_down = locked_down;

	g_object_notify (G_OBJECT (applet), "locked-down");
}
Esempio n. 8
0
/**
 * panel_applet_settings_new:
 * @applet: a #PanelApplet.
 * @schema: the name of the schema.
 *
 * Creates a new #GSettings object for the per-instance settings of @applet,
 * with a given schema.
 *
 * Returns: a new #GSettings object for the per-instance settings of @applet.
 **/
GSettings *
panel_applet_settings_new (PanelApplet *applet,
                           const char  *schema)
{
	g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
	g_return_val_if_fail (schema != NULL, NULL);

	if (!applet->priv->settings_path) {
		return NULL;
	}

	return g_settings_new_with_path (schema, applet->priv->settings_path);
}
Esempio n. 9
0
/**
 * panel_applet_set_flags:
 * @applet: a #PanelApplet.
 * @flags: #PanelAppletFlags to use for @applet.
 *
 * Sets the #PanelAppletFlags of @applet. Most of the time, at least
 * %PANEL_APPLET_EXPAND_MINOR should be used.
 **/
void
panel_applet_set_flags (PanelApplet      *applet,
			PanelAppletFlags  flags)
{
	g_return_if_fail (PANEL_IS_APPLET (applet));

	if (applet->priv->flags == flags)
		return;

	applet->priv->flags = flags;
	
	applet->priv->has_handle = (flags & PANEL_APPLET_HAS_HANDLE) != 0;

	g_object_notify (G_OBJECT (applet), "flags");
}
Esempio n. 10
0
static gboolean
panel_applet_can_focus (GtkWidget *widget)
{
	/*
	 * A PanelApplet widget can focus if it has a tooltip or it does 
	 * not have any focusable children.
	 */
	if (gtk_widget_get_has_tooltip (widget))
		return TRUE;

	if (!PANEL_IS_APPLET (widget))
		return FALSE;

	return !container_has_focusable_child (GTK_CONTAINER (widget));
}
/**
 * panel_applet_gconf_set_bool:
 * @applet: a #PanelApplet.
 * @key: a GConf key name.
 * @the_bool: new value for @key.
 * @error: a #GError, or %NULL.
 *
 * Convenience wrapper around gconf_client_set_bool() to update @key in the
 * per-instance GConf directory of @applet.
 *
 * Deprecated: 3.0: Use #GSettings to store per-instance settings.
 **/
void
panel_applet_gconf_set_bool (PanelApplet  *applet,
			     const gchar  *key,
			     gboolean      the_bool,
			     GError      **error)
{
	GConfClient  *client;
	gchar        *full_key;

	g_return_if_fail (PANEL_IS_APPLET (applet));

	full_key = panel_applet_gconf_get_full_key (applet, key);

	client = panel_applet_gconf_get_client ();

	gconf_client_set_bool (client, full_key, the_bool, error);

	g_free (full_key);
}
/**
 * panel_applet_gconf_set_value:
 * @applet: a #PanelApplet.
 * @key: a GConf key name.
 * @value: new value for @key.
 * @error: a #GError, or %NULL.
 *
 * Convenience wrapper around gconf_client_set_value() to update @key in the
 * per-instance GConf directory of @applet.
 *
 * Deprecated: 3.0: Use #GSettings to store per-instance settings.
 **/
void
panel_applet_gconf_set_value (PanelApplet  *applet,
			      const gchar  *key,
			      GConfValue   *value,
			      GError      **error)
{
	GConfClient  *client;
	gchar        *full_key;

	g_return_if_fail (PANEL_IS_APPLET (applet));

	full_key = panel_applet_gconf_get_full_key (applet, key);

	client = panel_applet_gconf_get_client ();

	gconf_client_set (client, full_key, value, error);

	g_free (full_key);
}
gchar *
mate_panel_applet_mateconf_get_full_key (MatePanelApplet *applet,
				 const gchar *key)
{
	gchar *prefs_key;
	gchar *full_key;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);

	if (!key)
		return NULL;

	prefs_key = mate_panel_applet_get_preferences_key (applet);

	full_key = g_strdup_printf ("%s/%s", prefs_key, key);

	g_free (prefs_key);

	return full_key;
}
Esempio n. 14
0
void
mc_load_preferences (MCData *mc)
{
    gchar **history;
    guint i;

    g_return_if_fail (mc != NULL);
    g_return_if_fail (PANEL_IS_APPLET (mc->applet));

    mc->preferences.show_default_theme = g_settings_get_boolean (mc->settings, KEY_SHOW_DEFAULT_THEME);
    mc->preferences.auto_complete_history = g_settings_get_boolean (mc->settings, KEY_AUTOCOMPLETE_HISTORY);
    mc->preferences.normal_size_x = MAX (g_settings_get_int (mc->settings, KEY_NORMAL_SIZE_X), 50);
    mc->preferences.normal_size_y = 48;
    mc->preferences.cmd_line_color_fg = g_strdup (g_settings_get_string (mc->settings, KEY_CMD_LINE_COLOR_FG));
    mc->preferences.cmd_line_color_bg = g_strdup (g_settings_get_string (mc->settings, KEY_CMD_LINE_COLOR_BG));

    g_signal_connect (mc->settings, "changed::" KEY_SHOW_DEFAULT_THEME,
	                  G_CALLBACK (show_default_theme_changed), mc);
	g_signal_connect (mc->settings, "changed::" KEY_AUTOCOMPLETE_HISTORY,
	                  G_CALLBACK (auto_complete_history_changed), mc);
	g_signal_connect (mc->settings, "changed::" KEY_NORMAL_SIZE_X,
	                  G_CALLBACK (normal_size_x_changed), mc);
	g_signal_connect (mc->settings, "changed::" KEY_CMD_LINE_COLOR_FG,
	                  G_CALLBACK (cmd_line_color_fg_changed), mc);
	g_signal_connect (mc->settings, "changed::" KEY_CMD_LINE_COLOR_BG,
	                  G_CALLBACK (cmd_line_color_bg_changed), mc);

    mc->preferences.macros = mc_load_macros (mc);

    g_signal_connect (mc->global_settings, "changed::" KEY_MACRO_PATTERNS,
	                  G_CALLBACK (macros_changed), mc);
	g_signal_connect (mc->global_settings, "changed::" KEY_MACRO_COMMANDS,
	                  G_CALLBACK (macros_changed), mc);

    mc->preferences.idle_macros_loader_id = 0;

    history = g_settings_get_strv (mc->settings, KEY_HISTORY);
    for (i = 0; history[i] != NULL; i++) {
        append_history_entry (mc, history[i], TRUE);
    }
}
/**
 * panel_applet_gconf_get_value:
 * @applet: a #PanelApplet.
 * @key: a GConf key name.
 * @error: a #GError, or %NULL.
 *
 * Convenience wrapper around gconf_client_get_value() to get the value of @key
 * in the per-instance GConf directory of @applet.
 *
 * Returns: the value of @key.
 *
 * Deprecated: 3.0: Use #GSettings to store per-instance settings.
 **/
GConfValue *
panel_applet_gconf_get_value (PanelApplet  *applet,
			      const gchar  *key,
			      GError      **error)
{
	GConfClient  *client;
	gchar        *full_key;
	GConfValue   *retval;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);

	full_key = panel_applet_gconf_get_full_key (applet, key);

	client = panel_applet_gconf_get_client ();

	retval = gconf_client_get (client, full_key, error);

	g_free (full_key);

	return retval;
}
/**
 * panel_applet_gconf_get_float:
 * @applet: a #PanelApplet.
 * @key: a GConf key name.
 * @error: a #GError, or %NULL.
 *
 * Convenience wrapper around gconf_client_get_float() to get the value of @key
 * in the per-instance GConf directory of @applet.
 *
 * Returns: the value of @key.
 *
 * Deprecated: 3.0: Use #GSettings to store per-instance settings.
 **/
gdouble
panel_applet_gconf_get_float (PanelApplet  *applet,
			      const gchar  *key,
			      GError      **error)
{
	GConfClient  *client;
	gchar        *full_key;
	gdouble       retval;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), 0.0);

	full_key = panel_applet_gconf_get_full_key (applet, key);

	client = panel_applet_gconf_get_client ();

	retval = gconf_client_get_float (client, full_key, error);

	g_free (full_key);

	return retval;
}
Esempio n. 17
0
/**
 * panel_applet_setup_menu:
 * @applet: a #PanelApplet.
 * @xml: a menu XML string..
 *
 * Sets up the context menu of @applet. @xml is a #GtkUIManager UI definition,
 * describing how to display the menu items. @action_group contains the
 * various #GtkAction that are referenced in @xml.
 *
 * See also the <link linkend="getting-started.context-menu">Context
 * Menu</link> section.
 **/
void
panel_applet_setup_menu (PanelApplet *applet,
                         const gchar *xml)
{
	gchar  *new_xml;
	GError *error = NULL;

	g_return_if_fail (PANEL_IS_APPLET (applet));
	g_return_if_fail (xml != NULL);

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

	new_xml = g_strdup_printf ("<interface><menu id=\"panel-applet-popup\">%s</menu></interface>\n", xml);
	gtk_builder_add_from_string (applet->priv->builder, new_xml, -1, &error);
	g_free (new_xml);

	if (error) {
		g_warning ("Error merging menus: %s\n", error->message);
		g_error_free (error);
	}
}
Esempio n. 18
0
static gboolean
seahorse_applet_fill (PanelApplet *applet)
{
    SeahorseApplet *sapplet = SEAHORSE_APPLET (applet);
    GtkAction	   *action;
    GtkActionGroup *action_group;
    gchar	   *ui_path;

    /* Insert Icons into Stock */ 
    seahorse_gtkstock_init ();
    seahorse_gtkstock_add_icons (clipboard_icons);
    g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);
    gtk_widget_show_all (GTK_WIDGET (applet));

    action_group = gtk_action_group_new ("Seahorse Applet Actions");
    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
    gtk_action_group_add_actions (action_group,
				  seahorse_applet_menu_actions,
				  G_N_ELEMENTS (seahorse_applet_menu_actions),
				  applet);
    ui_path = g_build_filename (SEAHORSE_UIDIR, "seahorseapplet-menu.xml", NULL);
    panel_applet_setup_menu_from_file (applet, ui_path, action_group);
    g_free (ui_path);

    if (panel_applet_get_locked_down (applet)) {
        action = gtk_action_group_get_action (action_group, "Props");
        gtk_action_set_visible (action, FALSE);
    }

    update_icon (sapplet);
    seahorse_gconf_notify_lazy (APPLET_SCHEMAS, (GConfClientNotifyFunc)gconf_notify, 
                                sapplet, GTK_WIDGET (applet));

    g_object_unref (action_group);
    
    return TRUE;
}
Esempio n. 19
0
/* Applets cannot set their orientation, so API is not public. */
static void
panel_applet_set_orient (PanelApplet       *applet,
                         PanelAppletOrient  orient)
{
	GtkStyleContext *context;

	g_return_if_fail (PANEL_IS_APPLET (applet));

	if (applet->priv->orient == orient)
		return;

	applet->priv->orient = orient;

	context = gtk_widget_get_style_context (GTK_WIDGET (applet));
	switch (orient) {
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
		gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
		break;
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
		gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
		break;
	default:
		g_assert_not_reached();
		break;
	}
	gtk_widget_reset_style (GTK_WIDGET (applet));

	g_signal_emit (G_OBJECT (applet),
		       panel_applet_signals [CHANGE_ORIENT],
		       0, orient);

	g_object_notify (G_OBJECT (applet), "orient");
}
Esempio n. 20
0
static gboolean 
panel_applet_focus (GtkWidget        *widget,
		    GtkDirectionType  dir)
{
	gboolean ret;
	GtkWidget *previous_focus_child;

	g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE);

	previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget));
	if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
		if (gtk_widget_get_has_tooltip (widget)) {
			gtk_widget_set_can_focus (widget, TRUE);
			gtk_widget_grab_focus (widget);
			gtk_widget_set_can_focus (widget, FALSE);
			return TRUE;
		}
	}
	ret = GTK_WIDGET_CLASS (panel_applet_parent_class)->focus (widget, dir);

	if (!ret && !previous_focus_child) {
		if (!gtk_widget_has_focus (widget))  {
			/*
			 * Applet does not have a widget which can focus so set
			 * the focus on the applet unless it already had focus
			 * because it had a tooltip.
			 */ 
			gtk_widget_set_can_focus (widget, TRUE);
			gtk_widget_grab_focus (widget);
			gtk_widget_set_can_focus (widget, FALSE);
			ret = TRUE;
		}
	}

	return ret;
}
Esempio n. 21
0
static void
wireless_applet_properties_dialog (BonoboUIComponent *uic,
				  WirelessApplet *applet)
{
	static GtkWidget *global_property_box = NULL,
		*glade_property_box = NULL;
	GtkWidget *pct, *dialog, *device;

	g_return_if_fail (PANEL_IS_APPLET (PANEL_APPLET (applet)));

	if (applet->prefs != NULL)
	{
		gtk_widget_show (applet->prefs);
		gtk_window_present (GTK_WINDOW (applet->prefs));
		return;
	}

	if (global_property_box == NULL) {
		xml = glade_xml_new (glade_file, NULL, NULL);
		glade_property_box = glade_xml_get_widget (xml,"dialog1");
	}

	applet->prefs = glade_property_box;
	gtk_window_set_resizable (GTK_WINDOW (applet->prefs), FALSE);

	pct = glade_xml_get_widget (xml, "pct_check_button");
	dialog = glade_xml_get_widget (xml, "dialog_check_button");
	device = glade_xml_get_widget (xml, "device_menu");

	/* Set the show-percent thingy */
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pct),
			applet->show_percent);
	g_signal_connect (GTK_OBJECT (pct),
			"toggled",
			GTK_SIGNAL_FUNC (wireless_applet_option_change),
			applet);
	gtk_object_set_data (GTK_OBJECT (applet->prefs),
			"show-percent-button", pct);

        /* Set the device menu */
	gtk_option_menu_remove_menu (GTK_OPTION_MENU (device));
	{
		GtkWidget *menu;
		GtkWidget *item;
		GList *d;
		int idx = 0, choice = 0;

		menu = gtk_menu_new ();

		for (d = applet->devices; d != NULL; d = g_list_next (d)) {
			item = gtk_menu_item_new_with_label ((char*)d->data);
			gtk_menu_shell_append  (GTK_MENU_SHELL (menu),item);
			gtk_object_set_data_full (GTK_OBJECT (item), 
					"device-selected",
					g_strdup (d->data),
					g_free);
			g_signal_connect (GTK_OBJECT (item),
					"activate",
					GTK_SIGNAL_FUNC (wireless_applet_option_change),
					applet);

			if ((applet->device != NULL)
					&& (d->data != NULL)
					&& strcmp (applet->device, d->data)==0)
			{
				choice = idx;
			}
			idx++;
		}
		if (applet->devices == NULL) {
			char *markup;
			GtkWidget *label;
			
			label = gtk_label_new (NULL);
			markup = g_strdup_printf ("<i>%s</i>",
					_("No Wireless Devices"));
			gtk_label_set_markup (GTK_LABEL (label), markup);
			g_free (markup);

			item = gtk_menu_item_new ();
			gtk_container_add (GTK_CONTAINER (item), label);
			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		}
		gtk_option_menu_set_menu (GTK_OPTION_MENU (device), menu);
		gtk_option_menu_set_history (GTK_OPTION_MENU (device), choice);
	}
	gtk_object_set_data (GTK_OBJECT (applet->prefs), "device-menu", device);

	g_signal_connect (GTK_OBJECT (applet->prefs),
			"response", 
			G_CALLBACK (prefs_response_cb),
			NULL);
	g_signal_connect (GTK_OBJECT (applet->prefs),
			"destroy",
			GTK_SIGNAL_FUNC (gtk_widget_destroy),
			NULL);

	g_object_add_weak_pointer (G_OBJECT (applet->prefs),
			(void**)&(applet->prefs));
	gtk_window_set_screen (GTK_WINDOW (applet->prefs),
			       gtk_widget_get_screen (GTK_WIDGET (applet)));
	gtk_widget_show_all (applet->prefs);
}
Esempio n. 22
0
void
mc_load_preferences (MCData *mc)
{
    MateConfValue *history;
    GError     *error = NULL;

    g_return_if_fail (mc != NULL);
    g_return_if_fail (PANEL_IS_APPLET (mc->applet));

    mc->preferences.show_default_theme =
		mate_panel_applet_mateconf_get_bool (mc->applet, "show_default_theme", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.show_default_theme = MC_DEFAULT_SHOW_DEFAULT_THEME;
    }

    mc->preferences.auto_complete_history =
		mate_panel_applet_mateconf_get_bool (mc->applet, "autocomplete_history", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.auto_complete_history = MC_DEFAULT_AUTO_COMPLETE_HISTORY;
    }

    mc->preferences.normal_size_x =
		mate_panel_applet_mateconf_get_int (mc->applet, "normal_size_x", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.normal_size_x = MC_DEFAULT_NORMAL_SIZE_X;
    }
    mc->preferences.normal_size_x = MAX (mc->preferences.normal_size_x, 50);

    mc->preferences.normal_size_y =
		mate_panel_applet_mateconf_get_int (mc->applet, "normal_size_y", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.normal_size_y = MC_DEFAULT_NORMAL_SIZE_Y;
    }
    mc->preferences.normal_size_y = CLAMP (mc->preferences.normal_size_y, 5, 200);

    mc->preferences.cmd_line_color_fg_r =
		mate_panel_applet_mateconf_get_int (mc->applet, "cmd_line_color_fg_r", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_fg_r = MC_DEFAULT_CMD_LINE_COLOR_FG_R;
    }

    mc->preferences.cmd_line_color_fg_g =
		mate_panel_applet_mateconf_get_int (mc->applet, "cmd_line_color_fg_g", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_fg_g = MC_DEFAULT_CMD_LINE_COLOR_FG_G;
    }

    mc->preferences.cmd_line_color_fg_b =
		mate_panel_applet_mateconf_get_int (mc->applet, "cmd_line_color_fg_b", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_fg_b = MC_DEFAULT_CMD_LINE_COLOR_FG_B;
    }

    mc->preferences.cmd_line_color_bg_r =
		mate_panel_applet_mateconf_get_int (mc->applet, "cmd_line_color_bg_r", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_bg_r = MC_DEFAULT_CMD_LINE_COLOR_BG_R;
    }

    mc->preferences.cmd_line_color_bg_g =
		mate_panel_applet_mateconf_get_int (mc->applet, "cmd_line_color_bg_g", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_bg_g = MC_DEFAULT_CMD_LINE_COLOR_BG_G;
    }

    mc->preferences.cmd_line_color_bg_b =
		mate_panel_applet_mateconf_get_int (mc->applet, "cmd_line_color_bg_b", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_bg_b = MC_DEFAULT_CMD_LINE_COLOR_BG_B;
    }

    mc->preferences.macros = mc_load_macros (mc);

    history = mate_panel_applet_mateconf_get_value (mc->applet, "history", NULL);
    if (history) {
        GSList *l;

	for (l = mateconf_value_get_list (history); l; l = l->next) {
            const char *entry = NULL;
            
            if ((entry = mateconf_value_get_string (l->data)))
                append_history_entry (mc, entry, TRUE);
        }
	
	mateconf_value_free (history);
    }

    mc_setup_listeners (mc);

    mc->preferences.idle_macros_loader_id = 0;
}
Esempio n. 23
0
static void
panel_applet_position_menu (GtkMenu   *menu,
			    int       *x,
			    int       *y,
			    gboolean  *push_in,
			    GtkWidget *widget)
{
	PanelApplet    *applet;
	GtkAllocation   allocation;
	GtkRequisition  requisition;
	GdkDevice      *device;
	GdkScreen      *screen;
	int             menu_x = 0;
	int             menu_y = 0;
	int             pointer_x;
	int             pointer_y;

	g_return_if_fail (PANEL_IS_APPLET (widget));

	applet = PANEL_APPLET (widget);

	screen = gtk_widget_get_screen (widget);
	
	gtk_menu_set_screen(menu, screen);

	gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
	gdk_window_get_origin (gtk_widget_get_window (widget),
			       &menu_x, &menu_y);
	device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (gtk_widget_get_display (widget)));
	gdk_window_get_device_position(gtk_widget_get_window (widget), device, &pointer_x, &pointer_y, NULL);

	gtk_widget_get_allocation (widget, &allocation);

	menu_x += allocation.x;
	menu_y += allocation.y;

	if (applet->priv->orient == PANEL_APPLET_ORIENT_UP ||
	    applet->priv->orient == PANEL_APPLET_ORIENT_DOWN) {
		if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) {
			if (pointer_x < allocation.width &&
			    requisition.width < pointer_x)
				menu_x += MIN (pointer_x,
					       allocation.width - requisition.width);
		} else {
			menu_x += allocation.width - requisition.width;
			if (pointer_x > 0 && pointer_x < allocation.width &&
			    pointer_x < allocation.width - requisition.width) {
				menu_x -= MIN (allocation.width - pointer_x,
					       allocation.width - requisition.width);
			}
		}
		menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width);

		if (menu_y > gdk_screen_get_height (screen) / 2)
			menu_y -= requisition.height;
		else
			menu_y += allocation.height;
	} else  {
		if (pointer_y < allocation.height &&
		    requisition.height < pointer_y)
			menu_y += MIN (pointer_y, allocation.height - requisition.height);
		menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height);

		if (menu_x > gdk_screen_get_width (screen) / 2)
			menu_x -= requisition.width;
		else
			menu_x += allocation.width;

	}

	*x = menu_x;
	*y = menu_y;
	*push_in = FALSE;
}