/* GTK - The GIMP Toolkit
* gtkrecentchooserdefault.c
* Copyright (C) 2005-2006, Emmanuele Bassi
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkeventbox.h"
#include "gtkexpander.h"
#include "gtkframe.h"
-#include "gtkhbox.h"
-#include "gtkhpaned.h"
+#include "gtkbox.h"
+#include "gtkpaned.h"
#include "gtkimage.h"
#include "gtkimagemenuitem.h"
#include "gtkintl.h"
#include "gtkseparatormenuitem.h"
#include "gtksizegroup.h"
#include "gtksizerequest.h"
-#include "gtktable.h"
#include "gtktreemodelsort.h"
#include "gtktreemodelfilter.h"
#include "gtktreeselection.h"
#include "gtktreestore.h"
#include "gtktooltip.h"
#include "gtktypebuiltins.h"
-#include "gtkvbox.h"
+#include "gtkorientable.h"
#include "gtkactivatable.h"
#include "gtkrecentmanager.h"
#include "gtkrecentchooserutils.h"
#include "gtkrecentchooserdefault.h"
-#include "gtkprivate.h"
-
enum
{
struct _GtkRecentChooserDefault
{
- GtkVBox parent_instance;
-
+ GtkBox parent_instance;
+
GtkRecentManager *manager;
gulong manager_changed_id;
guint local_manager : 1;
-
+
gint icon_size;
/* RecentChooser properties */
- gint limit;
+ gint limit;
GtkRecentSortType sort_type;
guint show_private : 1;
guint show_not_found : 1;
typedef struct _GtkRecentChooserDefaultClass
{
- GtkVBoxClass parent_class;
+ GtkBoxClass parent_class;
} GtkRecentChooserDefaultClass;
enum {
RECENT_URI_COLUMN,
RECENT_DISPLAY_NAME_COLUMN,
RECENT_INFO_COLUMN,
-
N_RECENT_COLUMNS
};
G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDefault,
_gtk_recent_chooser_default,
- GTK_TYPE_VBOX,
+ GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER,
gtk_recent_chooser_iface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
{
gtk_box_set_spacing (GTK_BOX (impl), 6);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (impl),
+ GTK_ORIENTATION_VERTICAL);
+
/* by default, we use the global manager */
impl->local_manager = FALSE;
-
+
impl->limit = FALLBACK_ITEM_LIMIT;
impl->sort_type = GTK_RECENT_SORT_NONE;
impl->load_id = 0;
}
- if (impl->recent_items)
- {
- g_list_foreach (impl->recent_items, (GFunc) gtk_recent_info_unref, NULL);
- g_list_free (impl->recent_items);
- impl->recent_items = NULL;
- }
+ g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
+ impl->recent_items = NULL;
if (impl->manager && impl->manager_changed_id)
{
gdk_display_flush (display);
if (cursor)
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
static void
/* we have finished loading, so we remove the items cache */
impl->load_state = LOAD_LOADING;
- g_list_foreach (impl->recent_items,
- (GFunc) gtk_recent_info_unref,
- NULL);
- g_list_free (impl->recent_items);
+ g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
impl->recent_items = NULL;
impl->n_recent_items = 0;
static void
set_default_size (GtkRecentChooserDefault *impl)
{
+ GtkScrolledWindow *scrollw;
GtkWidget *widget;
gint width, height;
- gint font_size;
+ double font_size;
GdkScreen *screen;
gint monitor_num;
GtkRequisition req;
GdkRectangle monitor;
+ GtkStyleContext *context;
+ GtkStateFlags state;
widget = GTK_WIDGET (impl);
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
/* Size based on characters and the icon size */
- font_size = pango_font_description_get_size (gtk_widget_get_style (widget)->font_desc);
- font_size = PANGO_PIXELS (font_size);
+ gtk_style_context_get (context, state, "font-size", &font_size, NULL);
- width = impl->icon_size + font_size * NUM_CHARS;
- height = (impl->icon_size + font_size) * NUM_LINES;
+ width = impl->icon_size + font_size * NUM_CHARS + 0.5;
+ height = (impl->icon_size + font_size) * NUM_LINES + 0.5;
/* Use at least the requisition size... */
gtk_widget_get_preferred_size (widget, &req, NULL);
monitor_num = gdk_screen_get_monitor_at_window (screen,
gtk_widget_get_window (widget));
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
width = MIN (width, monitor.width * 3 / 4);
height = MIN (height, monitor.height * 3 / 4);
/* Set size */
- gtk_widget_set_size_request (impl->recent_view, width, height);
+ scrollw = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (impl->recent_view));
+ gtk_scrolled_window_set_min_content_width (scrollw, width);
+ gtk_scrolled_window_set_min_content_height (scrollw, height);
}
static void
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
*x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
*y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
gpointer user_data)
{
GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data);
-
- if (event->button == 3)
+
+ if (gdk_event_triggers_context_menu ((GdkEvent *) event))
{
GtkTreePath *path;
gboolean res;