[gcalctool/gcalctool-newui2] ...



commit 8a50984c583bfbab9afc169709cbd5616131d43b
Author: Robert Ancell <robert ancell gmail com>
Date:   Wed Jul 15 10:52:19 2009 +1000

    ...

 src/gtk.c |   83 +++---------------------------------------------------------
 1 files changed, 5 insertions(+), 78 deletions(-)
---
diff --git a/src/gtk.c b/src/gtk.c
index deb2798..bb51f8e 100644
--- a/src/gtk.c
+++ b/src/gtk.c
@@ -491,8 +491,6 @@ do_finc(char* dialog)
 void
 ui_set_mode(ModeType mode)
 {
-    GtkRequisition *r;
-    gint w, h;
     char *hostname, title[MAXLINE];
     GtkWidget *menu;
 
@@ -520,39 +518,6 @@ ui_set_mode(ModeType mode)
     g_object_set(G_OBJECT(X.prog_panel), "visible", mode == PROGRAMMING, NULL);
     g_object_set(G_OBJECT(X.bit_panel), "visible", mode == PROGRAMMING, NULL);
     gtk_widget_set_sensitive(GET_WIDGET("show_registers_menu"), mode != BASIC);
-    
-    /* HACK: Some horrible hack down below to keep the buttons the same size.
-     * There must be a safer way of doing this... */
-    r = g_new0(GtkRequisition, 1);
-    gtk_widget_size_request(X.menubar, r);
-    w = r->width;
-    h = r->height;
-    gtk_widget_size_request(X.display_item, r);
-    w = MAX(w, r->width);
-    h += r->height;
-
-    if (GTK_WIDGET_VISIBLE(X.fin_panel)) {
-        gtk_widget_size_request(X.fin_panel, r);
-        w = MAX(w, r->width);
-        h += r->height;
-    }
-
-    if (GTK_WIDGET_VISIBLE(X.sci_panel)) {
-        gtk_widget_size_request(X.sci_panel, r);
-        w = MAX(w, r->width);
-        h += r->height;
-    }
-    
-    if (GTK_WIDGET_VISIBLE(X.prog_panel)) {
-        gtk_widget_size_request(X.prog_panel, r);
-        w = MAX(w, r->width);
-        h += r->height;
-    }
-    g_free(r);
-  
-    /* For initial display. */
-    gtk_window_set_default_size(GTK_WINDOW(X.main_window), w, h);
-    gtk_window_resize(GTK_WINDOW(X.main_window), w, h);
 
     /* Set the title */
     if((hostname = make_hostname())) {
@@ -661,7 +626,7 @@ ui_set_display(char *str, int cursor)
     if (cursor < 0) {
         adj = gtk_scrolled_window_get_hadjustment(
                  GTK_SCROLLED_WINDOW(X.scrolledwindow));
-        gtk_adjustment_set_value(adj, adj->upper - adj->page_size);
+        gtk_adjustment_set_value(adj, gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj));
     }
 }
 
@@ -719,8 +684,8 @@ ui_set_registers_visible(gboolean visible)
     gtk_widget_realize(X.register_dialog);
 
     if (visible) {
-        if (gdk_window_is_visible(X.register_dialog->window)) {
-            gdk_window_raise(X.register_dialog->window);
+        if (gdk_window_is_visible(gtk_widget_get_window(X.register_dialog))) {
+            gdk_window_raise(gtk_widget_get_window(X.register_dialog));
             return;
         }
         position_popup(X.main_window, X.register_dialog, POPUP_ABOVE);
@@ -1080,17 +1045,6 @@ create_register_model()
 }
 
 
-static void
-save_win_position()
-{
-    int x, y;
-
-    (void) gdk_window_get_origin(X.main_window->window, &x, &y);
-    set_int_resource(R_XPOS, x);
-    set_int_resource(R_YPOS, y);
-}
-
-
 G_MODULE_EXPORT
 gboolean
 bit_toggle_cb(GtkWidget *event_box, GdkEventButton *event)
@@ -1291,7 +1245,7 @@ popup_cb(GtkWidget *widget, GdkEventButton *event)
 
     menu = (GtkWidget *)g_object_get_data(G_OBJECT(widget), "calc_menu");
     if (event == NULL) {
-        gdk_window_get_origin(widget->window, &loc.x, &loc.y);
+        gdk_window_get_origin(gtk_widget_get_window(widget), &loc.x, &loc.y);
         loc.x += widget->allocation.x;
         loc.y += widget->allocation.y;
         gtk_menu_popup(GTK_MENU(menu), NULL, NULL, menu_pos_func,
@@ -1661,7 +1615,6 @@ G_MODULE_EXPORT
 void
 quit_cb(GtkWidget *widget)
 {
-    save_win_position();
     gtk_main_quit();
 }
 
@@ -1700,31 +1653,6 @@ preferences_dialog_delete_cb(GtkWidget *widget)
 
 
 static void
-set_win_position()
-{
-    int intval, screen_height, screen_width;
-    int x = 0, y = 0;
-
-    screen_width = gdk_screen_get_width(gdk_screen_get_default());
-    screen_height = gdk_screen_get_height(gdk_screen_get_default());
-
-    if (get_int_resource(R_XPOS, &intval)) {
-        x = intval;
-        if (x < 0 || x > screen_width)
-            x = 0;
-    }
-
-    if (get_int_resource(R_YPOS, &intval)) {
-        y = intval;
-        if (y < 0 || y > screen_height)
-            y = 0;
-    }
-
-    gtk_window_move(GTK_WINDOW(X.main_window), x, y);
-}
-
-
-static void
 create_main_window()
 {
     int i;
@@ -1842,7 +1770,7 @@ create_main_window()
 
     X.display_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(X.display_item));
     gtk_widget_ensure_style(X.display_item);
-    font_desc = pango_font_description_copy(X.display_item->style->font_desc);
+    font_desc = pango_font_description_copy(gtk_widget_get_style(X.display_item)->font_desc);
     pango_font_description_set_size(font_desc, 16 * PANGO_SCALE);
     gtk_widget_modify_font(X.display_item, font_desc);
     pango_font_description_free(font_desc);
@@ -1851,7 +1779,6 @@ create_main_window()
                                                   ATK_ROLE_EDITBAR);
 
     gtk_widget_realize(X.main_window);
-    set_win_position();
 
     X.status_image = GET_WIDGET("status_image");
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]