gint layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos) { if (!layout_valid(&lw)) return FALSE; if (!lw->tools || !GTK_WIDGET_VISIBLE(lw->tools)) { /* use the stored values (sort of breaks success return value) */ *divider_pos = lw->div_float; return FALSE; } gdk_window_get_root_origin(lw->tools->window, x, y); gdk_drawable_get_size(lw->tools->window, w, h); if (GTK_IS_VPANED(lw->tools_pane)) { *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.height; } else { *divider_pos = GTK_PANED(lw->tools_pane)->child1->allocation.width; } return TRUE; }
/** * 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); }
GimpSessionInfoBook * gimp_session_info_book_from_widget (GimpDockbook *dockbook) { GimpSessionInfoBook *info; GtkWidget *parent; GList *children; GList *list; g_return_val_if_fail (GIMP_IS_DOCKBOOK (dockbook), NULL); info = gimp_session_info_book_new (); parent = gtk_widget_get_parent (GTK_WIDGET (dockbook)); if (GTK_IS_VPANED (parent)) { GtkPaned *paned = GTK_PANED (parent); if (GTK_WIDGET (dockbook) == gtk_paned_get_child2 (paned)) info->position = gtk_paned_get_position (paned); } info->current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook)); children = gtk_container_get_children (GTK_CONTAINER (dockbook)); for (list = children; list; list = g_list_next (list)) { GimpSessionInfoDockable *dockable; dockable = gimp_session_info_dockable_from_widget (list->data); info->dockables = g_list_prepend (info->dockables, dockable); } info->dockables = g_list_reverse (info->dockables); g_list_free (children); return info; }
/** * 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); }