Esempio n. 1
0
LayoutWindow *layout_new(const gchar *path, gint popped, gint hidden)
{
	LayoutWindow *lw;
	GdkGeometry geometry;
	GdkWindowHints hints;

	lw = g_new0(LayoutWindow, 1);

	lw->thumbs_enabled = thumbnails_enabled;
	lw->sort_method = SORT_NAME;
	lw->sort_ascend = TRUE;

	lw->tools_float = popped;
	lw->tools_hidden = hidden;

	lw->toolbar_hidden = toolbar_hidden;

	lw->utility_box = NULL;
	lw->bar_sort = NULL;
	lw->bar_sort_enabled = FALSE;
	lw->bar_exif = NULL;
	lw->bar_exif_enabled = FALSE;
	lw->bar_exif_size = -1;
	lw->bar_exif_advanced = FALSE;

	lw->full_screen_overlay_id = -1;
	lw->full_screen_overlay_on = FALSE;

	/* default layout */

	layout_config_parse(layout_style, layout_order,
			    &lw->dir_location,  &lw->file_location, &lw->image_location);
	lw->tree_view = layout_view_tree;
	lw->icon_view = layout_view_icons;

	/* divider positions */

	if (save_window_positions)
		{
		lw->div_h = window_hdivider_pos;
		lw->div_v = window_vdivider_pos;
		lw->div_float = float_window_divider;
		}
	else
		{
		lw->div_h = MAIN_WINDOW_DIV_HPOS;
		lw->div_v = MAIN_WINDOW_DIV_VPOS;
		lw->div_float = MAIN_WINDOW_DIV_VPOS;
		}

	/* window */

	lw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_resizable(GTK_WINDOW(lw->window), TRUE);

	gtk_window_set_title(GTK_WINDOW(lw->window), "GQview");
	gtk_window_set_wmclass(GTK_WINDOW(lw->window), "gqview", "GQview");
	gtk_container_set_border_width(GTK_CONTAINER(lw->window), 0);

	window_set_icon(lw->window, NULL, NULL);

	if (save_window_positions)
		{
		hints = GDK_HINT_USER_POS;
		}
	else
		{
		hints = 0;
		}

	geometry.min_width = 32;
	geometry.min_height = 32;
	geometry.base_width = MAINWINDOW_DEF_WIDTH;
	geometry.base_height = MAINWINDOW_DEF_HEIGHT;
	gtk_window_set_geometry_hints(GTK_WINDOW(lw->window), NULL, &geometry,
				      GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | hints);

	if (save_window_positions)
		{
		gtk_window_set_default_size(GTK_WINDOW(lw->window), main_window_w, main_window_h);
		if (!layout_window_list)
			{
			gtk_window_move(GTK_WINDOW(lw->window), main_window_x, main_window_y);
			if (main_window_maximized) gtk_window_maximize(GTK_WINDOW(lw->window));
			}
		}
	else
		{
		gtk_window_set_default_size(GTK_WINDOW(lw->window), MAINWINDOW_DEF_WIDTH, MAINWINDOW_DEF_HEIGHT);
		}

	g_signal_connect(G_OBJECT(lw->window), "delete_event",
			 G_CALLBACK(layout_delete_cb), lw);

	layout_keyboard_init(lw, lw->window);

	lw->tooltips = gtk_tooltips_new();

	/* take ownership of tooltips */
#ifdef GTK_OBJECT_FLOATING
	/* GTK+ < 2.10 */
	g_object_ref(G_OBJECT(lw->tooltips));
	gtk_object_sink(GTK_OBJECT(lw->tooltips));
#else
	/* GTK+ >= 2.10 */
	g_object_ref_sink(G_OBJECT(lw->tooltips));
#endif

	lw->main_box = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(lw->window), lw->main_box);
	gtk_widget_show(lw->main_box);

	layout_grid_setup(lw);
	image_top_window_set_sync(lw->image, (lw->tools_float || lw->tools_hidden));

	layout_util_sync(lw);
	layout_status_update_all(lw);

	if (path)
		{
		layout_set_path(lw, path);
		}
	else
		{
		GdkPixbuf *pixbuf;

		pixbuf = pixbuf_inline(PIXBUF_INLINE_LOGO);
		image_change_pixbuf(lw->image, pixbuf, 1.0);
		gdk_pixbuf_unref(pixbuf);
		}

	/* set up the time stat timeout */
	lw->last_time = 0;
	lw->last_time_id = g_timeout_add(5000, layout_check_for_update_cb, lw);

	gtk_widget_show(lw->window);
	layout_tools_hide(lw, lw->tools_hidden);

	layout_window_list = g_list_append(layout_window_list, lw);

	return lw;
}
Esempio n. 2
0
static void options_parse_layout_end(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, gpointer data, GError **error)
{
	LayoutWindow *lw = data;
	layout_util_sync(lw);
}
Esempio n. 3
0
void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
{
	gchar *path;
	ImageWindow *old_image;

	if (!layout_valid(&lw)) return;

	if (style != -1)
		{
		LayoutLocation d, f, i;

		layout_config_parse(style, order, &d,  &f, &i);

		if (lw->dir_location == d &&
		    lw->file_location == f &&
		    lw->image_location == i) return;

		lw->dir_location = d;
		lw->file_location = f;
		lw->image_location = i;
		}

	/* remember state */

	layout_image_slideshow_stop(lw);
	layout_image_full_screen_stop(lw);

	path = lw->path;
	lw->path = NULL;
	old_image = lw->image;
	lw->image = NULL;
	lw->utility_box = NULL;

	layout_geometry_get_dividers(lw, &lw->div_h, &lw->div_v);

	/* clear it all */

	gtk_widget_hide(old_image->widget);
	gtk_widget_ref(old_image->widget);
	gtk_container_remove(GTK_CONTAINER(old_image->widget->parent), old_image->widget);

	lw->h_pane = NULL;
	lw->v_pane = NULL;

	lw->toolbar = NULL;
	lw->thumb_button = NULL;
	lw->path_entry = NULL;
	lw->dir_view = NULL;
	lw->vdl = NULL;
	lw->vdt = NULL;

	lw->file_view = NULL;
	lw->vfl = NULL;
	lw->vfi = NULL;

	lw->info_box = NULL;
	lw->info_progress_bar = NULL;
	lw->info_sort = NULL;
	lw->info_status = NULL;
	lw->info_details = NULL;
	lw->info_zoom = NULL;

	if (lw->ui_manager) g_object_unref(lw->ui_manager);
	lw->ui_manager = NULL;
	lw->action_group = NULL;

	gtk_container_remove(GTK_CONTAINER(lw->main_box), lw->group_box);
	lw->group_box = NULL;

	/* re-fill */

	layout_grid_setup(lw);
	layout_tools_hide(lw, lw->tools_hidden);

	layout_list_sync_sort(lw);
	layout_util_sync(lw);
	layout_status_update_all(lw);

	/* sync */

	if (image_get_path(old_image))
		{
		layout_set_path(lw, image_get_path(old_image));
		}
	else
		{
		layout_set_path(lw, path);
		}
	image_change_from_image(lw->image, old_image);
	image_top_window_set_sync(lw->image, (lw->tools_float || lw->tools_hidden));

	/* clean up */

	gtk_widget_unref(old_image->widget);
	g_free(path);
}