[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-user: gschem : minor beautification
Hello,
This patch place the scrollbars and the drawing area in a table, this prevents
that the scrollbars doesn't intersect in the bottom right corner.
--
Kam
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 5948c74..c0fc760 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -854,7 +854,7 @@ gint x_stroke_translate_and_execute (GSCHEM_TOPLEVEL *w_current);
void x_window_setup (GSCHEM_TOPLEVEL *w_current);
void x_window_setup_gc(GSCHEM_TOPLEVEL *w_current);
void x_window_free_gc(GSCHEM_TOPLEVEL *w_current);
-void x_window_create_drawing(GtkWidget *drawbox, GSCHEM_TOPLEVEL *w_current);
+void x_window_create_drawing(GtkWidget *draw_table, GSCHEM_TOPLEVEL *w_current);
void x_window_setup_draw_events(GSCHEM_TOPLEVEL *w_current);
void x_window_create_main(GSCHEM_TOPLEVEL *w_current);
void x_window_close(GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/src/x_window.c b/gschem/src/x_window.c
index 07beb6e..485df94 100644
--- a/gschem/src/x_window.c
+++ b/gschem/src/x_window.c
@@ -98,27 +98,20 @@ void x_window_free_gc(GSCHEM_TOPLEVEL *w_current)
* \par Function Description
*
*/
-void x_window_create_drawing(GtkWidget *drawbox, GSCHEM_TOPLEVEL *w_current)
+void x_window_create_drawing(GtkWidget *draw_table, GSCHEM_TOPLEVEL *w_current)
{
/* drawing next */
w_current->drawing_area = gtk_drawing_area_new ();
- /* Set the size here. Be sure that it has an aspect ratio of 1.333
- * We could calculate this based on root window size, but for now
- * lets just set it to:
- * Width = root_width*3/4 Height = Width/1.3333333333
- * 1.3333333 is the desired aspect ratio!
- */
- gtk_drawing_area_size (GTK_DRAWING_AREA (w_current->drawing_area),
- w_current->win_width,
- w_current->win_height);
+ gtk_widget_set_size_request (GTK_WIDGET (w_current->drawing_area),
+ 160, 120);
- gtk_box_pack_start (GTK_BOX (drawbox), w_current->drawing_area,
- TRUE, TRUE, 0);
- GTK_WIDGET_SET_FLAGS (w_current->drawing_area, GTK_CAN_FOCUS );
- gtk_widget_grab_focus (w_current->drawing_area);
- gtk_widget_show (w_current->drawing_area);
+ gtk_table_attach_defaults (GTK_TABLE (draw_table), w_current->drawing_area,
+ 0, 1, 0, 1);
+
+ gtk_widget_set_can_focus (w_current->drawing_area, TRUE);
+ gtk_widget_grab_focus (w_current->drawing_area);
}
/*! \todo Finish function documentation!!!
@@ -247,7 +240,7 @@ void x_window_create_main(GSCHEM_TOPLEVEL *w_current)
GtkWidget *label=NULL;
GtkWidget *main_box=NULL;
GtkWidget *menubar=NULL;
- GtkWidget *drawbox=NULL;
+ GtkWidget *draw_table=NULL;
GtkWidget *bottom_box=NULL;
GtkWidget *toolbar=NULL;
GtkWidget *handlebox=NULL;
@@ -258,12 +251,16 @@ void x_window_create_main(GSCHEM_TOPLEVEL *w_current)
w_current->main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (w_current->main_window, "gschem");
- gtk_window_set_policy (GTK_WINDOW (w_current->main_window), TRUE, TRUE, TRUE);
-
- /* We want the widgets to flow around the drawing area, so we don't
- * set a size of the main window. The drawing area's size is fixed,
- * see below
+
+ /* Set the size here. Be sure that it has an aspect ratio of 1.333
+ * We could calculate this based on root window size, but for now
+ * lets just set it to:
+ * Width = root_width*3/4 Height = Width/1.3333333333
+ * 1.3333333 is the desired aspect ratio!
*/
+ gtk_window_set_default_size (GTK_WINDOW (w_current->main_window),
+ w_current->win_width,
+ w_current->win_height);
/*
* normally we let the window manager handle locating and sizing
@@ -275,9 +272,9 @@ void x_window_create_main(GSCHEM_TOPLEVEL *w_current)
gtk_widget_set_uposition (w_current->main_window, 10, 10);
/* this should work fine */
- gtk_signal_connect (GTK_OBJECT (w_current->main_window), "delete_event",
- GTK_SIGNAL_FUNC (i_callback_close_wm),
- w_current);
+ g_signal_connect (G_OBJECT (w_current->main_window), "delete_event",
+ G_CALLBACK (i_callback_close_wm),
+ w_current);
/* Containers first */
main_box = gtk_vbox_new(FALSE, 1);
@@ -408,51 +405,47 @@ void x_window_create_main(GSCHEM_TOPLEVEL *w_current)
/* Try to create popup menu (appears in right mouse button */
w_current->popup_menu = (GtkWidget *) get_main_popup(w_current);
- drawbox = gtk_hbox_new(FALSE, 0);
- gtk_container_border_width(GTK_CONTAINER(drawbox), 0);
- gtk_container_add(GTK_CONTAINER(main_box), drawbox);
- x_window_create_drawing(drawbox, w_current);
- x_window_setup_draw_events(w_current);
+ draw_table = gtk_table_new (2, 2, FALSE);
+ gtk_box_pack_start (GTK_BOX (main_box), draw_table, TRUE, TRUE, 0);
- if (w_current->scrollbars_flag == TRUE) {
- /* setup scroll bars */
- w_current->v_adjustment =
- gtk_adjustment_new (toplevel->init_bottom,
- 0.0, toplevel->init_bottom,
- 100.0, 100.0, 10.0);
+ x_window_create_drawing (draw_table, w_current);
+ x_window_setup_draw_events (w_current);
- w_current->v_scrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (
- w_current->v_adjustment));
+ if (w_current->scrollbars_flag == TRUE)
+ {
+ /* setup scroll bars */
+ w_current->v_adjustment = gtk_adjustment_new (toplevel->init_bottom,
+ 0.0, toplevel->init_bottom,
+ 100.0, 100.0, 10.0);
- gtk_range_set_update_policy (GTK_RANGE (w_current->v_scrollbar),
- GTK_UPDATE_CONTINUOUS);
+ g_signal_connect (G_OBJECT (w_current->v_adjustment),
+ "value_changed",
+ G_CALLBACK (x_event_vschanged),
+ w_current);
- gtk_box_pack_start (GTK_BOX (drawbox), w_current->v_scrollbar,
- FALSE, FALSE, 0);
+ w_current->v_scrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (w_current->v_adjustment));
- gtk_signal_connect (GTK_OBJECT (w_current->v_adjustment),
- "value_changed",
- GTK_SIGNAL_FUNC (x_event_vschanged),
- w_current);
+ gtk_table_attach (GTK_TABLE (draw_table), w_current->v_scrollbar,
+ 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
w_current->h_adjustment = gtk_adjustment_new (0.0, 0.0,
toplevel->init_right,
100.0, 100.0, 10.0);
- w_current->h_scrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (
- w_current->h_adjustment));
-
- gtk_range_set_update_policy (GTK_RANGE (w_current->h_scrollbar),
- GTK_UPDATE_CONTINUOUS);
+ g_signal_connect (G_OBJECT (w_current->h_adjustment),
+ "value_changed",
+ G_CALLBACK (x_event_hschanged),
+ w_current);
- gtk_box_pack_start (GTK_BOX (main_box), w_current->h_scrollbar,
- FALSE, FALSE, 0);
+ w_current->h_scrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (w_current->h_adjustment));
- gtk_signal_connect (GTK_OBJECT (w_current->h_adjustment),
- "value_changed",
- GTK_SIGNAL_FUNC (x_event_hschanged),
- w_current);
+ gtk_table_attach (GTK_TABLE (draw_table), w_current->h_scrollbar,
+ 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
}
/* macro box */
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user