Beispiel #1
0
/**
 * A callback for when the position of a GtkPaned slider changes
 *
 * This function is responsible for storing the width or height of the Buddy
 * List as a preference after the user changes it by dragging the slider.
 *
 * @param[in] gobject    Pointer to the GtkPaned structure that was resized
 * @param[in] pspec      Unused
 * @param[in] data       Pointer to the Buddy List that is a parent of gobject
**/
static void notify_position_cb(GObject *gobject, U GParamSpec *pspec,
			       gpointer data)
{
	PidginBuddyList *
	    gtkblist;      /*< Buddy List window containing these panes */
	gint max_position; /*< The "max-position" property of gobject   */
	gint size;	 /*< Current size of the Buddy List pane      */

	gtkblist = data;
	size = gtk_paned_get_position(GTK_PANED(gobject));

	/* If the Buddy List is not the first pane, invert the size preference.
	 */
	if (gtk_paned_get_child1(GTK_PANED(gobject)) != gtkblist->notebook) {
		g_object_get(gobject, "max-position", &max_position, NULL);
		size = max_position - size;
	}

	/* Store this size as a user preference (depending on paned
	 * orientation). */
	if (GTK_IS_VPANED(gobject))
		purple_prefs_set_int(PREF_HEIGHT, size);
	else
		purple_prefs_set_int(PREF_WIDTH, size);
}
Beispiel #2
0
void
toggle_shrink (GtkWidget *widget,
               GtkWidget *child)
{
  GtkWidget *parent;
  GtkPaned *paned;
  gboolean is_child1;
  gboolean resize, shrink;

  parent = gtk_widget_get_parent (child);
  paned = GTK_PANED (parent);

  is_child1 = (child == gtk_paned_get_child1 (paned));

  gtk_container_child_get (GTK_CONTAINER (paned), child,
                           "resize", &resize,
                           "shrink", &shrink,
                           NULL);

  g_object_ref (child);
  gtk_container_remove (GTK_CONTAINER (parent), child);
  if (is_child1)
    gtk_paned_pack1 (paned, child, resize, !shrink);
  else
    gtk_paned_pack2 (paned, child, resize, !shrink);
  g_object_unref (child);
}
Beispiel #3
0
static void set_16_9_layout(gboolean layout_16_9)
{
	GtkWidget *paned;
	gboolean can_remove;

	g_return_if_fail(main_paned != NULL);
	g_return_if_fail(chat_panel != NULL);

	paned = gtk_paned_get_child1(GTK_PANED(main_paned));

	/* Increase reference count, otherwise it will be destroyed */
	g_object_ref(chat_panel);

	/* Initially the widget has no parent, and cannot be removed */
	can_remove = gtk_widget_get_parent(chat_panel) != NULL;

	if (layout_16_9) {
		if (can_remove)
			gtk_container_remove(GTK_CONTAINER(paned),
					     chat_panel);
		gtk_container_add(GTK_CONTAINER(main_paned), chat_panel);
	} else {
		if (can_remove)
			gtk_container_remove(GTK_CONTAINER(main_paned),
					     chat_panel);
		gtk_container_add(GTK_CONTAINER(paned), chat_panel);
	}
	g_object_unref(chat_panel);
}
gboolean
caja_navigation_window_sidebar_showing (CajaNavigationWindow *window)
{
    g_return_val_if_fail (CAJA_IS_NAVIGATION_WINDOW (window), FALSE);

    return (window->sidebar != NULL)
           && gtk_widget_get_visible (gtk_paned_get_child1 (GTK_PANED (window->details->content_paned)));
}
Beispiel #5
0
static gboolean get_16_9_layout(void)
{
	GtkWidget *paned;

	g_return_val_if_fail(main_paned != NULL, FALSE);
	g_return_val_if_fail(chat_panel != NULL, FALSE);

	paned = gtk_paned_get_child1(GTK_PANED(main_paned));
	if (gtk_widget_get_parent(chat_panel) == paned)
		return FALSE;
	return TRUE;
}
Beispiel #6
0
GtkWidget *
create_pane_options (GtkPaned    *paned,
                     const gchar *frame_label,
                     const gchar *label1,
                     const gchar *label2)
{
  GtkWidget *child1, *child2;
  GtkWidget *frame;
  GtkWidget *table;
  GtkWidget *label;
  GtkWidget *check_button;

  child1 = gtk_paned_get_child1 (paned);
  child2 = gtk_paned_get_child2 (paned);

  frame = gtk_frame_new (frame_label);
  g_object_set (frame, "margin", 4, NULL);

  table = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (frame), table);

  label = gtk_label_new (label1);
  gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);

  check_button = gtk_check_button_new_with_mnemonic ("_Resize");
  gtk_grid_attach (GTK_GRID (table), check_button, 0, 1, 1, 1);
  g_signal_connect (check_button, "toggled",
                    G_CALLBACK (toggle_resize), child1);

  check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
  gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
  g_signal_connect (check_button, "toggled",
                    G_CALLBACK (toggle_shrink), child1);

  label = gtk_label_new (label2);
  gtk_grid_attach (GTK_GRID (table), label, 1, 0, 1, 1);

  check_button = gtk_check_button_new_with_mnemonic ("_Resize");
  gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
  g_signal_connect (check_button, "toggled",
                    G_CALLBACK (toggle_resize), child2);

  check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
  gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
  g_signal_connect (check_button, "toggled",
                    G_CALLBACK (toggle_shrink), child2);

  return frame;
}
Beispiel #7
0
static void prefs_show_sections(PrefsWindow *prefswindow)
{
	gint max;
	GtkWidget *paned = prefswindow->paned;
	
        g_object_get (G_OBJECT(paned),
                        "max-position",
                        &max, NULL);

	gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
	gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
	gtk_paned_set_position(GTK_PANED(paned), max);
}
Beispiel #8
0
int
clip_GTK_PANEDGETCHILD1(ClipMachine * cm)
{
	C_widget  *cpan = _fetch_cw_arg(cm);
        GtkWidget  *wid ;
        C_widget  *cwid ;

	CHECKCWID(cpan,GTK_IS_PANED);

	wid = gtk_paned_get_child1(GTK_PANED(cpan->widget));

        if (wid)
        {
        	cwid = _list_get_cwidget(cm, wid);
                if (!cwid) cwid = _register_widget(cm, wid, NULL);
                if (cwid) _clip_mclone(cm, RETPTR(cm), &cwid->obj);
        }

	return 0;
err:
	return 1;
}
Beispiel #9
0
/**
 * A callback for when the total size of a GtkPaned changes
 *
 * This should be called after a new GtkPaned finds its parent and calculates
 * its "max-position" property.  It is only intended to be run on this single
 * occassion, so it removes itself on completion.  The call is used to set the
 * initial size of the Buddy List to the user's preference.
 *
 * @param[in] gobject    Pointer to the GtkPaned structure that was resized
 * @param[in] pspec      Unused
 * @param[in] data       Pointer to the Buddy List that is a parent of gobject
**/
static void notify_max_position_cb(GObject *gobject, U GParamSpec *pspec,
				   gpointer data)
{
	PidginBuddyList *
	    gtkblist;      /*< Buddy List window containing these panes */
	gint max_position; /*< The "max-position" property of gobject   */
	gint size;	 /*< Desired size of the Buddy List pane      */

	gtkblist = data;

	/* Fetch the user's preferred Buddy List size (depending on
	 * orientation). */
	if (GTK_IS_VPANED(gobject))
		size = purple_prefs_get_int(PREF_HEIGHT);
	else
		size = purple_prefs_get_int(PREF_WIDTH);

	/* If the Buddy List is not the first pane, invert the size preference.
	 */
	if (gtk_paned_get_child1(GTK_PANED(gobject)) != gtkblist->notebook) {
		g_object_get(gobject, "max-position", &max_position, NULL);
		size = max_position - size;
	}

	/* Adjust the panes' slider to set the Buddy List to its desired size.
	 */
	gtk_paned_set_position(GTK_PANED(gobject), size);

	/* Disconnect this callback.  This initial setting was only needed once.
	 */
	g_object_disconnect(gobject, "any_signal",
			    G_CALLBACK(notify_max_position_cb), data, NULL);

	/* Now that system-induced slider changes are done, monitor user
	 * changes. */
	g_object_connect(gobject, "signal::notify::position",
			 G_CALLBACK(notify_position_cb), data, NULL);
}
Beispiel #10
0
static void
gth_auto_paned_size_allocate (GtkWidget     *widget,
			 GtkAllocation *allocation)
{
	GthAutoPaned  *self = GTH_AUTO_PANED (widget);
	GtkWidget *child1;
	GtkWidget *child2;
	gboolean   reset_position;

	child1 = gtk_paned_get_child1 (GTK_PANED (self));
	child2 = gtk_paned_get_child2 (GTK_PANED (self));

	reset_position = FALSE;
	if ((self->priv->child1_visible != _gtk_widget_get_visible (child1))
	    || (self->priv->child2_visible != _gtk_widget_get_visible (child2)))
	{
		reset_position = TRUE;
		self->priv->child1_visible = _gtk_widget_get_visible (child1);
		self->priv->child2_visible = _gtk_widget_get_visible (child2);
	}

	if (reset_position) {
		int position;

		switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (self))) {
		case GTK_ORIENTATION_HORIZONTAL:
			position = allocation->width / 2;
			break;
		case GTK_ORIENTATION_VERTICAL:
			position = allocation->height / 2;
			break;
		}
		gtk_paned_set_position (GTK_PANED (self), position);
	}

	GTK_WIDGET_CLASS (gth_auto_paned_parent_class)->size_allocate (widget, allocation);
}
void
brasero_file_chooser_customize (GtkWidget *widget, gpointer null_data)
{
	/* we explore everything until we reach a treeview (there are two) */
	if (GTK_IS_TREE_VIEW (widget)) {
		GtkTargetList *list;
		GdkAtom target;
		gboolean found;
		guint num;

		list = gtk_drag_source_get_target_list (widget);
		target = gdk_atom_intern ("text/uri-list", TRUE);
		found = gtk_target_list_find (list, target, &num);
		/* FIXME: should we unref them ? apparently not according to 
		 * the warning messages we get if we do */

		if (found
		&&  gtk_tree_selection_get_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget))) == GTK_SELECTION_MULTIPLE) {
			GtkTreeModel *model;

			/* This is done because GtkFileChooser does not use a
			 * GtkListStore or GtkTreeStore any more. */
			egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (widget));
			model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
			if (model) {
				GType type;

				type = G_OBJECT_TYPE (model);
				brasero_enable_multi_DND_for_model_type (type);
			}
			else
				g_signal_connect (widget,
				                  "notify::model",
				                  G_CALLBACK (brasero_file_chooser_notify_model),
				                  NULL);
		}
	}
	else if (GTK_IS_BUTTON (widget)) {
		GtkWidget *image;
		gchar *stock_id = NULL;

		image = gtk_button_get_image (GTK_BUTTON (widget));
		if (!GTK_IS_IMAGE (image))
			return;

		gtk_image_get_stock (GTK_IMAGE (image), &stock_id, NULL);
		if (stock_id
		&& (!strcmp (stock_id,GTK_STOCK_ADD)
		||  !strcmp (stock_id, GTK_STOCK_REMOVE))) {
			GtkRequisition request;
			gint width;
			GtkWidget *parent;

			/* This is to avoid having the left part too small */
			parent = gtk_widget_get_parent (widget);
			gtk_widget_get_requisition (parent, &request);
			width = request.width;
			gtk_widget_get_preferred_size (parent, &request, NULL);
			if (request.width >= width)
				gtk_widget_set_size_request (parent,
							     request.width,
							     request.height);
			
			gtk_widget_hide (widget);
		}
	}
	else if (GTK_IS_CONTAINER (widget)) {
		if (GTK_IS_PANED (widget)) {
			GtkWidget *left;

			/* This is to allow the left part to be shrunk as much 
			 * as the user want. */
			left = gtk_paned_get_child1 (GTK_PANED (widget));

			g_object_ref (left);
			gtk_container_remove (GTK_CONTAINER (widget), left);
			gtk_paned_pack1 (GTK_PANED (widget),
					 left,
					 TRUE,
					 TRUE);
			g_object_unref (left);

			g_signal_connect (widget,
			                  "size-allocate",
			                  G_CALLBACK (brasero_file_chooser_allocation_changed),
			                  NULL);
		}

		gtk_container_foreach (GTK_CONTAINER (widget),
				       brasero_file_chooser_customize,
				       NULL);
	}
}