static void
panel_desktop_menu_item_append_menu (GtkWidget *menu,
				     gpointer   data)
{
	PanelDesktopMenuItem *parent;
	gboolean              add_separator;
	GList                *children;
	GList                *last;

	parent = PANEL_DESKTOP_MENU_ITEM (data);

	add_separator = FALSE;
	children = gtk_container_get_children (GTK_CONTAINER (menu));
	last = g_list_last (children);

	if (last != NULL)
		add_separator = !GTK_IS_SEPARATOR (GTK_WIDGET (last->data));

	g_list_free (children);

	if (add_separator)
		add_menu_separator (menu);

	panel_menu_items_append_from_desktop (menu, "yelp.desktop", NULL);
	panel_menu_items_append_from_desktop (menu, "gnome-about.desktop", NULL);

	if (parent->priv->append_lock_logout)
		panel_menu_items_append_lock_logout (menu);
}
Exemple #2
0
static void
panel_desktop_menu_item_append_menu (GtkWidget *menu,
				     gpointer   data)
{
	PanelDesktopMenuItem *parent;
	gboolean              add_separator;
	GList                *children;
	GList                *last;

	parent = PANEL_DESKTOP_MENU_ITEM (data);

	add_separator = FALSE;
	children = gtk_container_get_children (GTK_CONTAINER (menu));
	last = g_list_last (children);

	if (last != NULL)
		add_separator = !GTK_IS_SEPARATOR (GTK_WIDGET (last->data));

	g_list_free (children);

	if (add_separator)
		add_menu_separator (menu);

	/* FIXME replace this with MATE documentation system, when it will be ready
	 * see: http://forums.mate-desktop.org/viewtopic.php?f=17&t=805
	
	panel_menu_items_append_from_desktop (menu, "yelp.desktop", NULL, FALSE);
	*/

	panel_menu_items_append_from_desktop (menu, "mate-about.desktop", NULL, FALSE);

	if (parent->priv->append_lock_logout)
		panel_menu_items_append_lock_logout (menu);
}
/* We are trying to implement the following rules here:
 *
 * rule 1: never ever show separators for empty sections
 * rule 2: always show a separator if there is a label
 * rule 3: don't show a separator for the first section
 * rule 4: don't show a separator for the following sections if there are
 *         no items before it
 * (rule 5: these rules don't apply exactly the same way for subsections)
 */
void
gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
                                      gint              *n_items)
{
  gboolean should_have_separator;
  gboolean has_separator;
  gboolean has_label;
  gint n_items_before = *n_items;

  gtk_container_foreach (GTK_CONTAINER (box->item_box), gtk_menu_section_box_sync_item, n_items);

  if (box->separator == NULL)
    return;

  has_separator = gtk_widget_get_parent (box->separator) != NULL;
  has_label = !GTK_IS_SEPARATOR (box->separator);

  should_have_separator = (has_label || (n_items_before > 0 && box->depth <= 1)) && *n_items > n_items_before;

  if (should_have_separator == has_separator)
    return;

  if (should_have_separator)
    gtk_box_pack_start (GTK_BOX (box), box->separator, FALSE, FALSE, 0);
  else
    gtk_container_remove (GTK_CONTAINER (box), box->separator);
}
Exemple #4
0
static void
main_menu_append (GtkWidget *main_menu,
		  gpointer   data)
{
	PanelWidget *panel;
	GtkWidget   *item;
	gboolean     add_separator;
	GList       *children;
	GList       *last;

	panel = PANEL_WIDGET (data);

	add_separator = FALSE;
	children = gtk_container_get_children (GTK_CONTAINER (main_menu));
	last = g_list_last (children);
	if (last != NULL) {
		add_separator = !GTK_IS_SEPARATOR (GTK_WIDGET (last->data));
	}
	g_list_free (children);

	if (add_separator)
		add_menu_separator (main_menu);

	item = panel_place_menu_item_new (TRUE);
	panel_place_menu_item_set_panel (item, panel);
	gtk_menu_shell_append (GTK_MENU_SHELL (main_menu), item);
	gtk_widget_show (item);

	item = panel_desktop_menu_item_new (TRUE, FALSE);
	panel_desktop_menu_item_set_panel (item, panel);
	gtk_menu_shell_append (GTK_MENU_SHELL (main_menu), item);
	gtk_widget_show (item);

	panel_menu_items_append_lock_logout (main_menu);
}
Exemple #5
0
static void
cv_tabs_prune (chanview *cv)
{
    GList *boxes, *children;
    GtkWidget *box, *inner;
    GtkWidget *child;
    int empty;

    inner = ((tabview *)cv)->inner;
    boxes = gtk_container_get_children (GTK_CONTAINER (inner));
    while (boxes)
    {
        child = boxes->data;
        box = child;
        boxes = boxes->next;

        /* check if the box is empty (except a vseperator) */
        empty = TRUE;
        children = gtk_container_get_children (GTK_CONTAINER (box));
        while (children)
        {
            if (!GTK_IS_SEPARATOR ((GtkWidget *)children->data))
            {
                empty = FALSE;
                break;
            }
            children = children->next;
        }

        if (empty)
            gtk_widget_destroy (box);
    }
}
Exemple #6
0
static void
cv_tabs_move (chan *ch, int delta)
{
    int i = 0;
    int pos = 0;
    GList *list;
    GtkWidget *parent = gtk_widget_get_parent(GTK_WIDGET (ch->impl));

    for (list = gtk_container_get_children (GTK_CONTAINER (parent)); list; list = list->next)
    {
        GtkWidget *child_entry;

        child_entry = list->data;
        if (child_entry == ch->impl)
            pos = i;

        /* keep separator at end to not throw off our count */
        if (GTK_IS_SEPARATOR (child_entry))
            gtk_box_reorder_child (GTK_BOX (parent), child_entry, -1);
        else
            i++;
    }

    pos = (pos - delta) % i;
    gtk_box_reorder_child (GTK_BOX (parent), ch->impl, pos);
}
static void getGtkComboBoxPieces(GtkWidget* widget, gpointer data)
{
    if (GTK_IS_ARROW(widget)) {
        static_cast<ComboBoxWidgetPieces*>(data)->arrow = widget;
        return;
    }
    if (GTK_IS_SEPARATOR(widget)) 
        static_cast<ComboBoxWidgetPieces*>(data)->separator = widget;
}
Exemple #8
0
/* We are trying to implement the following rules here:
 *
 * rule 1: never ever show separators for empty sections
 * rule 2: always show a separator if there is a label
 * rule 3: don't show a separator for the first section
 * rule 4: don't show a separator for the following sections if there are
 *         no items before it
 * rule 5: never show separators directly above or below an iconic box
 * (rule 6: these rules don't apply exactly the same way for subsections)
 */
void
gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
                                      MenuData          *data)
{
  GtkWidget *parent_widget;
  gboolean previous_section_is_iconic;
  gboolean should_have_separator;
  gboolean should_have_top_margin = FALSE;
  gboolean is_not_empty_item;
  gboolean has_separator;
  gboolean has_label;
  gboolean separator_condition;
  gint n_items_before;

  n_items_before =  data->n_items;
  previous_section_is_iconic = data->previous_is_iconic;

  gtk_container_foreach (GTK_CONTAINER (box->item_box), gtk_menu_section_box_sync_item, data);

  is_not_empty_item = (data->n_items > n_items_before);

  if (is_not_empty_item)
    data->previous_is_iconic = box->iconic;

  if (box->separator == NULL)
    return;

  has_separator = gtk_widget_get_parent (box->separator) != NULL;
  has_label = !GTK_IS_SEPARATOR (box->separator);

  separator_condition = has_label ? TRUE : n_items_before > 0 &&
                                           box->depth <= 1 &&
                                           !previous_section_is_iconic &&
                                           !box->iconic;

  should_have_separator = separator_condition && is_not_empty_item;

  should_have_top_margin = !should_have_separator &&
                           (box->depth <= 1 || box->iconic) &&
                           n_items_before > 0 &&
                           is_not_empty_item;

  gtk_widget_set_margin_top (GTK_WIDGET (box->item_box), should_have_top_margin ? 10 : 0);

  if (should_have_separator == has_separator)
    return;

  if (should_have_separator)
    gtk_box_pack_start (GTK_BOX (box), box->separator, FALSE, FALSE, 0);
  else
    gtk_container_remove (GTK_CONTAINER (box), box->separator);
}
Exemple #9
0
static void
moz_gtk_get_combo_box_button_inner_widgets(GtkWidget *widget,
                                           gpointer client_data)
{
    if (GTK_IS_SEPARATOR(widget)) {
        gParts->comboBoxSeparatorWidget = widget;
        g_object_add_weak_pointer(G_OBJECT(widget),
                                  (gpointer) &gParts->comboBoxSeparatorWidget);
    } else if (GTK_IS_ARROW(widget)) {
        gParts->comboBoxArrowWidget = widget;
        g_object_add_weak_pointer(G_OBJECT(widget),
                                  (gpointer) &gParts->comboBoxArrowWidget);
    } else
        return;
    gtk_widget_realize(widget);
    g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
}
Exemple #10
0
static void
tab_add_sorted (chanview *cv, GtkWidget *box, GtkWidget *tab, chan *ch)
{
    GList *list;
    GtkWidget *child;
    int i = 0;
    void *b;

    if (!cv->sorted)
    {
        gtk_box_pack_start (GTK_BOX (box), tab, 0, 0, 0);
        gtk_widget_show (tab);
        return;
    }

    /* sorting TODO:
     *   - move tab if renamed (dialogs) */

    /* userdata, passed to mg_tabs_compare() */
    b = ch->userdata;

    list = gtk_container_get_children (GTK_CONTAINER (box));
    while (list)
    {
        child = list->data;
        if (!GTK_IS_SEPARATOR (child))
        {
            void *a = g_object_get_data (G_OBJECT (child), "u");

            if (ch->tag == 0 && cv->cb_compare (a, b) > 0)
            {
                gtk_box_pack_start (GTK_BOX (box), tab, 0, 0, 0);
                gtk_box_reorder_child (GTK_BOX (box), tab, ++i);
                gtk_widget_show (tab);
                return;
            }
        }
        i++;
        list = list->next;
    }

    /* append */
    gtk_box_pack_start (GTK_BOX (box), tab, 0, 0, 0);
    gtk_box_reorder_child (GTK_BOX (box), tab, i);
    gtk_widget_show (tab);
}
Exemple #11
0
static int
tab_group_for_each_tab (chanview *cv,
                        int (*callback) (GtkWidget *tab, int num, int usernum),
                        int usernum)
{
    GList *tabs;
    GList *boxes;
    GtkWidget *child;
    GtkBox *innerbox;
    int i;

    innerbox = (GtkBox *) ((tabview *)cv)->inner;
    boxes = gtk_container_get_children (GTK_CONTAINER (innerbox));
    i = 0;
    while (boxes)
    {
        child = boxes->data;
        tabs = gtk_container_get_children (GTK_CONTAINER (child));

        while (tabs)
        {
            child = tabs->data;

            if (!GTK_IS_SEPARATOR (child))
            {
                if (callback (child, i, usernum) != -1)
                    return i;
                i++;
            }
            tabs = tabs->next;
        }

        boxes = boxes->next;
    }

    return i;
}
Exemple #12
0
void
panel_menu_items_append_lock_logout (GtkWidget *menu)
{
	gboolean    separator_inserted;
	GList      *children;
	GList      *last;
	GtkWidget  *item;
	const char *translate;
	char       *label;
	char       *tooltip;

	separator_inserted = FALSE;
	children = gtk_container_get_children (GTK_CONTAINER (menu));
	last = g_list_last (children);
	if (last != NULL) {
		separator_inserted = GTK_IS_SEPARATOR (GTK_WIDGET (last->data));
	}
	g_list_free (children);

	if (panel_lock_screen_action_available("lock"))
	{
		item = panel_menu_items_create_action_item(PANEL_ACTION_LOCK);

		if (item != NULL)
		{
			if (!separator_inserted)
			{
				add_menu_separator(menu);
				separator_inserted = TRUE;
			}

			gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
		}
	}

	if (panel_lockdown_get_disable_log_out ())
		return;
	/* Below this, we only have log out/shutdown items */

	/* Translators: translate "1" (msgctxt: "panel:showusername") to anything
	 * but "1" if "Log Out %s" doesn't make any sense in your
	 * language (where %s is a username).
	 */
	translate = C_("panel:showusername", "1");
	if (strcmp (translate, "1") == 0) {
		const char *user_name;

		user_name = g_get_real_name ();
		if (!user_name || !user_name [0])
			user_name = g_get_user_name ();

		/* keep those strings in sync with the ones in
		 * panel-action-button.c */
		/* Translators: this string is used ONLY if you translated
		 * "1" (msgctxt: "panel:showusername") to "1" */
		label = g_strdup_printf (_("Log Out %s..."),
					 g_get_user_name ());
		/* Translators: this string is used ONLY if you translated
		 * "1" (msgctxt: "panel:showusername") to "1" */
		tooltip = g_strdup_printf (_("Log out %s of this session to "
					     "log in as a different user"),
					   user_name);
	} else {
		label   = NULL;
		tooltip = NULL;
	}

	item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT,
							 label, tooltip);
	g_free (label);
	g_free (tooltip);

	if (item != NULL) {
		if (!separator_inserted) {
			add_menu_separator (menu);
			separator_inserted = TRUE;
		}

		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
	}

	item = panel_menu_items_create_action_item (PANEL_ACTION_SHUTDOWN);
	if (item != NULL && !g_getenv("LTSP_CLIENT")) {
		if (!separator_inserted)
			add_menu_separator (menu);

		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
	}
}
Exemple #13
0
static void
tab_add_real (chanview *cv, GtkWidget *tab, chan *ch)
{
    GList *boxes, *children;
    GtkWidget *sep, *box, *inner;
    GtkWidget *child;
    int empty;

    inner = ((tabview *)cv)->inner;
    /* see if a family for this tab already exists */
    boxes = gtk_container_get_children (GTK_CONTAINER (inner));
    while (boxes)
    {
        child = boxes->data;
        box = child;

        if (g_object_get_data (G_OBJECT (box), "f") == ch->family)
        {
            tab_add_sorted (cv, box, tab, ch);
            gtk_widget_queue_resize (gtk_widget_get_parent(inner));
            return;
        }

        boxes = boxes->next;

        /* check if the box is empty (except a vseperator) */
        empty = TRUE;
        children = gtk_container_get_children (GTK_CONTAINER (box));
        while (children)
        {
            if (!GTK_IS_SEPARATOR ((GtkWidget *)children->data))
            {
                empty = FALSE;
                break;
            }
            children = children->next;
        }

        if (empty)
            gtk_widget_destroy (box);
    }

    /* create a new family box */
    if (cv->vertical)
    {
        /* vertical */
        box = gtk_vbox_new (FALSE, 0);
        sep = gtk_hseparator_new ();
    } else
    {
        /* horiz */
        box = gtk_hbox_new (FALSE, 0);
        sep = gtk_vseparator_new ();
    }

    gtk_box_pack_end (GTK_BOX (box), sep, 0, 0, 4);
    gtk_widget_show (sep);
    gtk_box_pack_start (GTK_BOX (inner), box, 0, 0, 0);
    g_object_set_data (G_OBJECT (box), "f", ch->family);
    gtk_box_pack_start (GTK_BOX (box), tab, 0, 0, 0);
    gtk_widget_show (tab);
    gtk_widget_show (box);
    gtk_widget_queue_resize (gtk_widget_get_parent(inner));
}
Exemple #14
0
void
panel_menu_items_append_lock_logout (GtkWidget *menu)
{
	GList      *children;
	GList      *last;
	GtkWidget  *item;

	children = gtk_container_get_children (GTK_CONTAINER (menu));
	last = g_list_last (children);
	if (last != NULL &&
	    GTK_IS_SEPARATOR (last->data))
		item = GTK_WIDGET (last->data);
	else
		item = add_menu_separator (menu);
	g_list_free (children);

	panel_lockdown_on_notify (panel_lockdown_get (),
				  NULL,
				  G_OBJECT (item),
				  panel_menu_items_lock_logout_separator_notified,
				  item);
	panel_menu_items_lock_logout_separator_notified (panel_lockdown_get (),
							 item);

	item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOCK,
							 NULL, NULL, TRUE);
	if (item != NULL) {
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		g_object_bind_property (panel_lockdown_get (),
					"disable-lock-screen",
					item,
					"visible",
					G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
	}

	item = panel_menu_items_create_switch_user (FALSE);

	if (item != NULL) {
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		g_object_bind_property (panel_lockdown_get (),
					"disable-switch-user",
					item,
					"visible",
					G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
	}

	item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT,
							 NULL, NULL, TRUE);

	if (item != NULL) {
		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
		g_object_bind_property (panel_lockdown_get (),
					"disable-log-out",
					item,
					"visible",
					G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
	}

	/* FIXME: should be dynamic */
	if (panel_session_manager_is_shutdown_available (panel_session_manager_get ())) {
		item = panel_menu_items_create_action_item_full (PANEL_ACTION_SHUTDOWN,
								 NULL, NULL, TRUE);
		if (item != NULL) {
			GtkWidget *sep;

			sep = add_menu_separator (menu);

			gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

			g_object_bind_property (panel_lockdown_get (),
						"disable-log-out",
						sep,
						"visible",
						G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
			g_object_bind_property (panel_lockdown_get (),
						"disable-log-out",
						item,
						"visible",
						G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
		}
	}
}