summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/gtkext/gtkbufferview.c4
-rw-r--r--src/gui/panels/glance.c119
3 files changed, 113 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index ac2fce9..2e512f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
14-09-11 Cyrille Bagard <nocbos@gmail.com>
+ * src/gtkext/gtkbufferview.c:
+ Typo. Fix debug code.
+
+ * src/gui/panels/glance.c:
+ Display a default picture when no panel overview is available.
+
+14-09-11 Cyrille Bagard <nocbos@gmail.com>
+
* src/gui/tb/Makefile.am:
* src/gui/tb/portions.c:
* src/gui/tb/portions.h:
diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c
index 8e1a9c7..87928b9 100644
--- a/src/gtkext/gtkbufferview.c
+++ b/src/gtkext/gtkbufferview.c
@@ -363,8 +363,8 @@ static gboolean gtk_buffer_view_draw(GtkWidget *widget, cairo_t *cr)
gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH);
- gtk_render_background (context, cr, 0, area.y, view->left_margin, 300000);
- gtk_render_frame (context, cr, 0, area.y - 10, view->left_margin, area.height + 20);
+ gtk_render_background (context, cr, 0, area.y, view->left_margin, area.height);
+ gtk_render_frame(context, cr, 0, area.y - 10, view->left_margin, area.height + 20);
gtk_style_context_restore(context);
diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c
index 89acf5c..0cb190a 100644
--- a/src/gui/panels/glance.c
+++ b/src/gui/panels/glance.c
@@ -65,6 +65,10 @@ struct _GGlancePanelClass
{
GPanelItemClass parent; /* A laisser en premier */
+ GtkIconInfo *no_image_32; /* Pas d'aperçu en 32x32 */
+ GtkIconInfo *no_image_64; /* Pas d'aperçu en 64x64 */
+ GtkIconInfo *no_image_128; /* Pas d'aperçu en 128x128 */
+
};
@@ -136,6 +140,7 @@ static void g_glance_panel_class_init(GGlancePanelClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
GEditorItemClass *editem; /* Encore une autre vision... */
+ GtkIconTheme *theme; /* Thème GTK offrant des icones*/
object = G_OBJECT_CLASS(klass);
@@ -147,6 +152,12 @@ static void g_glance_panel_class_init(GGlancePanelClass *klass)
editem->update_view = (update_item_view_fc)update_glance_panel_for_view;
editem->update_content = (update_item_view_fc)update_glance_panel_for_view_content;
+ theme = gtk_icon_theme_get_default();
+
+ klass->no_image_32 = gtk_icon_theme_lookup_icon(theme, "image-missing", 32, GTK_ICON_LOOKUP_FORCE_SIZE);
+ klass->no_image_64 = gtk_icon_theme_lookup_icon(theme, "image-missing", 64, GTK_ICON_LOOKUP_FORCE_SIZE);
+ klass->no_image_128 = gtk_icon_theme_lookup_icon(theme, "image-missing", 128, GTK_ICON_LOOKUP_FORCE_SIZE);
+
}
@@ -179,8 +190,6 @@ static void g_glance_panel_init(GGlancePanel *panel)
gtk_container_add(GTK_CONTAINER(base->widget), area);
gtk_widget_show(base->widget);
- gtk_widget_set_size_request(base->widget, 300, 300);
-
g_signal_connect(G_OBJECT(area), "draw",
G_CALLBACK(redraw_glance_area), panel);
g_signal_connect(G_OBJECT(area), "size-allocate",
@@ -349,7 +358,12 @@ static void update_glance_panel_for_view(GGlancePanel *panel, GtkViewPanel *view
}
+ /**
+ * Pour le détail de la hiérarchie, se retourner vers les commentaires
+ * de la fonction mcb_view_change_support().
+ */
parent = gtk_widget_get_parent(GTK_WIDGET(view));
+ parent = gtk_widget_get_parent(parent);
if (!GTK_IS_SCROLLED_WINDOW(parent)) return;
panel->view = view;
@@ -393,12 +407,12 @@ static void on_view_scroll_setup(GtkAdjustment *adj, GGlancePanel *panel)
if (gtk_adjustment_get_page_size(hadj) == 0 || gtk_adjustment_get_page_size(vadj) == 0)
return;
+ gtk_widget_get_preferred_size(GTK_WIDGET(panel->view), NULL, &panel->req);
+
compute_glance_scale(panel);
on_view_scrolled(adj, panel);
- gtk_widget_get_preferred_size(GTK_WIDGET(panel->view), NULL, &panel->req);
-
update_glance_panel_for_view_content(panel, panel->view);
}
@@ -478,7 +492,7 @@ static void on_glance_resize(GtkWidget *widget, GdkRectangle *allocation, GGlanc
static void compute_glance_scale(GGlancePanel *panel)
{
GtkAllocation available; /* Surface disponible totale */
- gint border; /* Taille de la bordure */
+ //gint border; /* Taille de la bordure */
double sx; /* Echelle sur l'axe X */
double sy; /* Echelle sur l'axe Y */
@@ -505,6 +519,14 @@ static void compute_glance_scale(GGlancePanel *panel)
sx = (1.0 * available.width) / panel->req.width;
sy = (1.0 * available.height) / panel->req.height;
+
+ printf(" -- avail :: (%d ; %d)\n", available.width, available.height);
+
+ printf(" -- req :: (%d ; %d)\n", panel->req.width, panel->req.height);
+
+ printf(" -- ratio >> (%g ; %g)\n", sx, sy);
+
+
if (sx < sy)
{
panel->scale = sx;
@@ -585,21 +607,78 @@ static void update_glance_panel_for_view_content(GGlancePanel *panel, GtkViewPan
static gboolean redraw_glance_area(GtkWidget *widget, cairo_t *cr, GGlancePanel *panel)
{
- GtkAllocation available; /* Surface disponible totale */
- cairo_t *cairo; /* Gestionnaire de rendu */
-#if 0
- /* Dessin de la bordure */
+ GtkAllocation alloc; /* Surface disponible totale */
+ GdkWindow *window; /* Fenêtre à redessiner */
+ GtkStyleContext *context; /* Contexte du thème actuel */
+ gint size; /* Taille d'icone à dessiner */
+ GtkIconInfo *no_image; /* Pas d'aperçu en XxX */
+ cairo_surface_t *icon; /* Eventuelle icone à dessiner */
- gtk_widget_get_allocation(widget, &available);
+ gtk_widget_get_allocation(widget, &alloc);
- gtk_paint_box(widget->style, event->window, widget->state,
- GTK_SHADOW_IN, &event->area, NULL, NULL,
- 0, 0, available.width, available.height);
+ window = gtk_widget_get_window(widget);
- /* Dessin de l'aperçu */
+ cairo_save(cr);
+ gtk_cairo_transform_to_window(cr, widget, window);
- if (panel->cache != NULL)
+ context = gtk_widget_get_style_context(widget);
+ gtk_style_context_save(context);
+
+ /* S'il n'existe pas d'aperçu actuellement... */
+ if (panel->cache == NULL)
+ {
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW);
+ gtk_render_background(context, cr, alloc.x, alloc.y, alloc.width, alloc.height);
+ gtk_style_context_restore(context);
+
+ gtk_style_context_save(context);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_FRAME);
+ gtk_render_frame(context, cr, alloc.x, alloc.y, alloc.width, alloc.height);
+
+ /* Choix de l'image par défaut */
+
+ if (alloc.width > 128 && alloc.height > 128)
+ {
+ size = 128;
+ no_image = G_GLANCE_PANEL_GET_CLASS(panel)->no_image_128;
+ }
+ else if (alloc.width > 64 && alloc.height > 64)
+ {
+ size = 64;
+ no_image = G_GLANCE_PANEL_GET_CLASS(panel)->no_image_64;
+ }
+ else if (alloc.width > 32 && alloc.height > 32)
+ {
+ size = 32;
+ no_image = G_GLANCE_PANEL_GET_CLASS(panel)->no_image_32;
+ }
+ else
+ no_image = NULL;
+
+ /* Dessin de cette image */
+ if (no_image != NULL)
+ {
+ icon = gtk_icon_info_load_surface(no_image, window, NULL);
+
+ gtk_render_icon_surface(context, cr, icon,
+ (alloc.width - size) / 2,
+ (alloc.height - size) / 2);
+
+ cairo_surface_destroy(icon);
+
+ }
+
+ }
+
+ /* Si on dispose de graphique à représenter... */
+ else
{
+
+ /* TODO ... */
+
+
+#if 0
+
cairo = gdk_cairo_create(widget->window);
cairo_rectangle(cairo, panel->visible.x, panel->visible.y,
@@ -621,8 +700,16 @@ static gboolean redraw_glance_area(GtkWidget *widget, cairo_t *cr, GGlancePanel
cairo_destroy(cairo);
- }
#endif
+
+
+
+ }
+
+ gtk_style_context_restore(context);
+
+ cairo_restore(cr);
+
return TRUE;
}