Mail Archives: geda-user/2012/02/08/11:15:10
This is a multi-part message in MIME format.
--------------020800020002040509070305
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Folks!
The migration check-list for GTK+ version 3 suggests
the compiler option -DGTK_DISABLE_SINGLE_INCLUDES.
GTK+ expects to have just gtk.h and gdk.h included.
This compiler option checks, whether or not the code
contains more gtk or gdk headers.
This is a minor fist step, afterwards one can try using
-DGDK_DISABLE_DEPRECATED and -DGTK_DISABLE_DEPRECATED
(I didn't today)
There were some of such issues in gattrib/src/gtksheet_2_2.c
which I fixed. I cleaned up some more code. there were
lots of assigned but unused variables, which I removed.
This patch (format-patch) is against my local HEAD.
The changes were tested using gattrib with a file
containing lots of attributes. :-)
As always, please tell me, if something is wrong. I try to correct it then.
Best regards
Eike
--------------020800020002040509070305
Content-Type: text/x-diff;
name="0001-I-compiled-using-the-compiler-option.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0001-I-compiled-using-the-compiler-option.patch"
From 72ce4e87a10c06abcb9890b6604e200d5f498281 Mon Sep 17 00:00:00 2001
From: eikekrumbacher <eike DOT krumbacher AT x-eike DOT de>
Date: Wed, 8 Feb 2012 16:51:52 +0100
Subject: [PATCH] I compiled using the compiler option
-DGTK_DISABLE_SINGLE_INCLUDES
This option looks for needless extra included
gtk and gdk headers. The only place was
gattrib/src/gtksheet_2_2.c
where I fixed the includes and looked for unused
but maybe assigned variables, which I removed.
Minor code cleanup in this file.
Tested gattrib with a file.
---
gattrib/src/gtksheet_2_2.c | 151 ++++----------------------------------------
1 files changed, 12 insertions(+), 139 deletions(-)
diff --git a/gattrib/src/gtksheet_2_2.c b/gattrib/src/gtksheet_2_2.c
index f23ff8d..9780964 100644
--- a/gattrib/src/gtksheet_2_2.c
+++ b/gattrib/src/gtksheet_2_2.c
@@ -31,18 +31,7 @@
#include <glib-object.h>
#include <gobject/gvaluecollector.h>
#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkadjustment.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbox.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtktypeutils.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkcontainer.h>
-#include <gtk/gtkpixmap.h>
+#include <gtk/gtk.h>
#include <pango/pango.h>
#include "gtksheet_2_2.h"
#include "gtkextra-marshal.h"
@@ -1331,9 +1320,6 @@ gtk_sheet_locked (GtkSheet *sheet)
void
gtk_sheet_set_title(GtkSheet *sheet, const gchar *title)
{
-/* GtkWidget *old_widget;
-*/ GtkWidget *label;
-
g_return_if_fail (sheet != NULL);
g_return_if_fail (title != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
@@ -1347,32 +1333,7 @@ gtk_sheet_set_title(GtkSheet *sheet, const gchar *title)
if(GTK_BIN(sheet->button)->child)
label = GTK_BIN(sheet->button)->child;
-/*
- gtk_label_set_text(GTK_LABEL(label), title);
-*/
- size_allocate_global_button(sheet);
-
- /* remove and destroy the old widget */
-/*
- old_widget = GTK_BIN (sheet->button)->child;
- if (old_widget)
- {
- gtk_container_remove (GTK_CONTAINER (sheet->button), old_widget);
- }
-
- label = gtk_label_new (title);
- gtk_misc_set_alignment(GTK_MISC(label), 0.5 , 0.5 );
-
- gtk_container_add (GTK_CONTAINER (sheet->button), label);
- gtk_widget_show (label);
-
size_allocate_global_button(sheet);
-
- gtk_signal_emit(GTK_OBJECT(sheet),sheet_signals[CHANGED], -1, -1);
-
- if(old_widget)
- gtk_widget_destroy (old_widget);
-*/
}
void
@@ -2608,16 +2569,12 @@ static void
gtk_sheet_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
- GtkSheet *sheet;
-
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_SHEET (widget));
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(*GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous_style);
- sheet = GTK_SHEET (widget);
-
if(GTK_WIDGET_REALIZED(widget))
{
gtk_style_set_background (widget->style, widget->window, widget->state);
@@ -2976,8 +2933,7 @@ gtk_sheet_unmap (GtkWidget * widget)
static void
gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col)
{
- GtkWidget *widget;
- GdkGC *fg_gc, *bg_gc;
+ GdkGC *bg_gc;
GtkSheetCellAttr attributes;
GdkRectangle area;
@@ -2991,15 +2947,12 @@ gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col)
if (!sheet->column[col].is_visible) return;
if (!sheet->row[row].is_visible) return;
- widget = GTK_WIDGET (sheet);
-
gtk_sheet_get_attributes(sheet, row, col, &attributes);
/* select GC for background rectangle */
gdk_gc_set_foreground (sheet->fg_gc, &attributes.foreground);
gdk_gc_set_foreground (sheet->bg_gc, &attributes.background);
- fg_gc = sheet->fg_gc;
bg_gc = sheet->bg_gc;
area.x=COLUMN_LEFT_XPIXEL(sheet,col);
@@ -3031,8 +2984,6 @@ gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col)
static void
gtk_sheet_cell_draw_border (GtkSheet *sheet, gint row, gint col, gint mask)
{
- GtkWidget *widget;
- GdkGC *fg_gc, *bg_gc;
GtkSheetCellAttr attributes;
GdkRectangle area;
guint width;
@@ -3047,17 +2998,12 @@ gtk_sheet_cell_draw_border (GtkSheet *sheet, gint row, gint col, gint mask)
if (!sheet->column[col].is_visible) return;
if (!sheet->row[row].is_visible) return;
- widget = GTK_WIDGET (sheet);
-
gtk_sheet_get_attributes(sheet, row, col, &attributes);
/* select GC for background rectangle */
gdk_gc_set_foreground (sheet->fg_gc, &attributes.border.color);
gdk_gc_set_foreground (sheet->bg_gc, &attributes.background);
- fg_gc = sheet->fg_gc;
- bg_gc = sheet->bg_gc;
-
area.x=COLUMN_LEFT_XPIXEL(sheet,col);
area.y=ROW_TOP_YPIXEL(sheet,row);
area.width=sheet->column[col].width;
@@ -3100,13 +3046,12 @@ gtk_sheet_cell_draw_border (GtkSheet *sheet, gint row, gint col, gint mask)
static void
gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
{
- GtkWidget *widget;
GdkRectangle area, clip_area;
gint i;
- gint text_width, text_height, y;
+ gint text_width, y;
gint xoffset=0;
gint size, sizel, sizer;
- GdkGC *fg_gc, *bg_gc;
+ GdkGC *fg_gc;
GtkSheetCellAttr attributes;
PangoLayout *layout;
PangoRectangle rect;
@@ -3114,7 +3059,7 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
PangoLayoutLine *line;
PangoFontMetrics *metrics;
PangoContext *context = gtk_widget_get_pango_context(GTK_WIDGET(sheet));
- gint ascent, descent, y_pos;
+ gint y_pos;
char *label;
@@ -3137,8 +3082,6 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
if (!sheet->row[row].is_visible) return;
- widget = GTK_WIDGET(sheet);
-
label = sheet->data[row][col]->text;
gtk_sheet_get_attributes(sheet, row, col, &attributes);
@@ -3148,7 +3091,6 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
gdk_gc_set_foreground (sheet->bg_gc, &attributes.background);
fg_gc = sheet->fg_gc;
- bg_gc = sheet->bg_gc;
area.x=COLUMN_LEFT_XPIXEL(sheet,col);
area.y=ROW_TOP_YPIXEL(sheet,row);
@@ -3169,9 +3111,6 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
attributes.font_desc,
pango_context_get_language(context));
- ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
- descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
-
pango_font_metrics_unref(metrics);
/* Align primarily for locale's ascent/descent */
@@ -3188,7 +3127,6 @@ gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
y_pos = area.height - logical_rect.height;
text_width = rect.width;
- text_height = rect.height;
y = area.y + y_pos - CELLOFFSET;
switch(attributes.justification){
@@ -3408,7 +3346,6 @@ gtk_sheet_range_draw_selection(GtkSheet *sheet, GtkSheetRange range)
{
GdkRectangle area;
gint i,j;
- GtkSheetRange aux;
if(range.col0 > sheet->range.coli || range.coli < sheet->range.col0 ||
range.row0 > sheet->range.rowi || range.rowi < sheet->range.row0)
@@ -3417,8 +3354,6 @@ gtk_sheet_range_draw_selection(GtkSheet *sheet, GtkSheetRange range)
if(!gtk_sheet_range_isvisible(sheet, range)) return;
if(!GTK_WIDGET_REALIZED(GTK_WIDGET(sheet))) return;
- aux=range;
-
range.col0=MAX(sheet->range.col0, range.col0);
range.coli=MIN(sheet->range.coli, range.coli);
range.row0=MAX(sheet->range.row0, range.row0);
@@ -3660,14 +3595,12 @@ static void
gtk_sheet_real_cell_clear (GtkSheet *sheet, gint row, gint column, gboolean delete)
{
gchar *text;
- gpointer link;
if(row > sheet->maxallocrow || column > sheet->maxalloccol) return;
if(!sheet->data[row]) return;
if(!sheet->data[row][column]) return;
text = gtk_sheet_cell_get_text(sheet, row, column);
- link = gtk_sheet_get_link(sheet, row, column);
if(text){
g_free(sheet->data[row][column]->text);
@@ -4134,7 +4067,6 @@ gtk_sheet_show_active_cell(GtkSheet *sheet)
GtkEntry *sheet_entry;
GtkSheetCellAttr attributes;
gchar *text = NULL;
- GtkJustification justification;
gint row, col;
g_return_if_fail (sheet != NULL);
@@ -4157,11 +4089,6 @@ gtk_sheet_show_active_cell(GtkSheet *sheet)
gtk_sheet_get_attributes(sheet, row, col, &attributes);
- justification = GTK_JUSTIFY_LEFT;
-
- if(gtk_sheet_justify_entry(sheet))
- justification = attributes.justification;
-
if(row <= sheet->maxallocrow && col <= sheet->maxalloccol) {
if(sheet->data[row]) {
if(sheet->data[row][col]) {
@@ -4513,13 +4440,10 @@ gtk_sheet_new_selection(GtkSheet *sheet, GtkSheetRange *range)
static void
gtk_sheet_draw_border (GtkSheet *sheet, GtkSheetRange new_range)
{
- GtkWidget *widget;
GdkRectangle area;
gint i;
gint x,y,width,height;
- widget = GTK_WIDGET(sheet);
-
x=COLUMN_LEFT_XPIXEL(sheet,new_range.col0);
y=ROW_TOP_YPIXEL(sheet,new_range.row0);
width=COLUMN_LEFT_XPIXEL(sheet,new_range.coli)-x+
@@ -6171,7 +6095,6 @@ gtk_sheet_size_allocate_entry(GtkSheet *sheet)
GtkSheetCellAttr attributes;
GtkEntry *sheet_entry;
GtkStyle *style = NULL, *previous_style = NULL;
- gint row, col;
gint size, max_size, text_size, column_width;
const gchar *text;
@@ -6226,9 +6149,6 @@ gtk_sheet_size_allocate_entry(GtkSheet *sheet)
size=MIN(text_size, max_size);
size=MAX(size,column_width-2*CELLOFFSET);
- row=sheet->active_cell.row;
- col=sheet->active_cell.col;
-
shentry_allocation.x = COLUMN_LEFT_XPIXEL(sheet,sheet->active_cell.col);
shentry_allocation.y = ROW_TOP_YPIXEL(sheet,sheet->active_cell.row);
shentry_allocation.width = column_width;
@@ -6248,16 +6168,10 @@ gtk_sheet_size_allocate_entry(GtkSheet *sheet)
static void
create_sheet_entry(GtkSheet *sheet)
{
- GtkWidget *widget;
GtkWidget *parent;
GtkWidget *entry;
- GtkStyle *style;
gint found_entry = FALSE;
- widget = GTK_WIDGET(sheet);
-
- style = gtk_style_copy(GTK_WIDGET(sheet)->style);
-
if(sheet->sheet_entry){
/* avoids warnings */
gtk_widget_ref(sheet->sheet_entry);
@@ -6693,26 +6607,16 @@ static void
vadjustment_changed (GtkAdjustment * adjustment,
gpointer data)
{
- GtkSheet *sheet;
-
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
-
- sheet = GTK_SHEET (data);
-
}
static void
hadjustment_changed (GtkAdjustment * adjustment,
gpointer data)
{
- GtkSheet *sheet;
-
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
-
- sheet = GTK_SHEET (data);
-
}
@@ -6721,7 +6625,7 @@ vadjustment_value_changed (GtkAdjustment * adjustment,
gpointer data)
{
GtkSheet *sheet;
- gint diff, value, old_value;
+ gint value;
gint i;
gint row, new_row;
gint y=0;
@@ -6738,8 +6642,6 @@ vadjustment_value_changed (GtkAdjustment * adjustment,
if(!sheet->column_titles_visible)
row=ROW_FROM_YPIXEL(sheet,CELL_SPACING);
- old_value = -sheet->voffset;
-
for(i=0; i<= sheet->maxrow; i++){
if(sheet->row[i].is_visible) y+=sheet->row[i].height;
if(y > adjustment->value) break;
@@ -6781,18 +6683,7 @@ vadjustment_value_changed (GtkAdjustment * adjustment,
value = adjustment->value;
- if (value >= -sheet->voffset)
- {
- /* scroll down */
- diff = value + sheet->voffset;
- }
- else
- {
- /* scroll up */
- diff = -sheet->voffset - value;
- }
-
- sheet->voffset = -value;
+ sheet->voffset = -value;
sheet->view.row0=ROW_FROM_YPIXEL(sheet, sheet->column_title_area.height+1);
sheet->view.rowi=ROW_FROM_YPIXEL(sheet, sheet->sheet_window_height-1);
@@ -6828,7 +6719,7 @@ hadjustment_value_changed (GtkAdjustment * adjustment,
gpointer data)
{
GtkSheet *sheet;
- gint i, diff, value, old_value;
+ gint i, value;
gint column, new_column;
gint x=0;
@@ -6844,8 +6735,6 @@ hadjustment_value_changed (GtkAdjustment * adjustment,
if(!sheet->row_titles_visible)
column=COLUMN_FROM_XPIXEL(sheet, CELL_SPACING);
- old_value = -sheet->hoffset;
-
for(i=0; i<= sheet->maxcol; i++){
if(sheet->column[i].is_visible) x+=sheet->column[i].width;
if(x > adjustment->value) break;
@@ -6887,17 +6776,6 @@ hadjustment_value_changed (GtkAdjustment * adjustment,
value = adjustment->value;
- if (value >= -sheet->hoffset)
- {
- /* scroll right */
- diff = value + sheet->hoffset;
- }
- else
- {
- /* scroll left */
- diff = -sheet->hoffset - value;
- }
-
sheet->hoffset = -value;
sheet->view.col0=COLUMN_FROM_XPIXEL(sheet, sheet->row_title_area.width+1);
@@ -8025,14 +7903,12 @@ static gint
DeleteColumn(GtkSheet *tbl, gint column, gint ncols)
{
gint i,j;
- GtkSheetColumn auxcol;
ncols = MIN(ncols,tbl->maxcol-column+1);
if(ncols <= 0 || column > tbl->maxcol) return TRUE;
for(i=column; i<column+ncols; i++){
- auxcol=tbl->column[i];
if(tbl->column[i].name){
g_free(tbl->column[i].name);
tbl->column[i].name = NULL;
@@ -8515,7 +8391,6 @@ gtk_sheet_position_child(GtkSheet *sheet, GtkSheetChild *child)
GtkAllocation child_allocation;
gint xoffset = 0;
gint yoffset = 0;
- gint x = 0, y = 0;
GdkRectangle area;
gtk_widget_get_child_requisition(child->widget, &child_requisition);
@@ -8583,15 +8458,13 @@ gtk_sheet_position_child(GtkSheet *sheet, GtkSheetChild *child)
child_allocation.height = child_requisition.height;
}
- x = child_allocation.x = child->x + xoffset;
- y = child_allocation.y = child->y + yoffset;
}
else
{
- x = child_allocation.x = child->x + sheet->hoffset + xoffset;
- x = child_allocation.x = child->x + xoffset;
- y = child_allocation.y = child->y + sheet->voffset + yoffset;
- y = child_allocation.y = child->y + yoffset;
+ child_allocation.x = child->x + sheet->hoffset + xoffset;
+ child_allocation.x = child->x + xoffset;
+ child_allocation.y = child->y + sheet->voffset + yoffset;
+ child_allocation.y = child->y + yoffset;
child_allocation.width = child_requisition.width;
child_allocation.height = child_requisition.height;
}
--
1.7.5.4
--------------020800020002040509070305--
- Raw text -