< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c

Print this page

        

@@ -561,12 +561,12 @@
 
     /*
      * Strip the AT-SPI GTK_MODULEs if present
      */
     gtk_modules_env = getenv ("GTK_MODULES");
-    if (gtk_modules_env && strstr (gtk_modules_env, "atk-bridge") ||
-        gtk_modules_env && strstr (gtk_modules_env, "gail"))
+    if ((gtk_modules_env && strstr (gtk_modules_env, "atk-bridge")) ||
+        (gtk_modules_env && strstr (gtk_modules_env, "gail")))
     {
         /* the new env will be smaller than the old one */
         gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc,
                 sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env));
 

@@ -576,11 +576,11 @@
             gchar *tmp_env = strdup (gtk_modules_env);
             strcpy(new_env, ENV_PREFIX);
 
             /* strip out 'atk-bridge' and 'gail' */
             size_t PREFIX_LENGTH = strlen(ENV_PREFIX);
-            while (s = strtok(tmp_env, ":"))
+            while ((s = strtok(tmp_env, ":")))
             {
                 if ((!strstr (s, "atk-bridge")) && (!strstr (s, "gail")))
                 {
                     if (strlen (new_env) > PREFIX_LENGTH) {
                         new_env = strcat (new_env, ":");

@@ -895,26 +895,29 @@
     GtkWidget *result = NULL;
     switch (widget_type)
     {
         case BUTTON:
         case TABLE_HEADER:
-            if (init_result = (NULL == gtk3_widgets[_GTK_BUTTON_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_BUTTON_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_BUTTON_TYPE] = (*fp_gtk_button_new)();
             }
             result = gtk3_widgets[_GTK_BUTTON_TYPE];
             break;
         case CHECK_BOX:
-            if (init_result = (NULL == gtk3_widgets[_GTK_CHECK_BUTTON_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_CHECK_BUTTON_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_CHECK_BUTTON_TYPE] =
                     (*fp_gtk_check_button_new)();
             }
             result = gtk3_widgets[_GTK_CHECK_BUTTON_TYPE];
             break;
         case CHECK_BOX_MENU_ITEM:
-            if (init_result = (NULL == gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE] =
                     (*fp_gtk_check_menu_item_new)();
             }
             result = gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE];

@@ -931,49 +934,54 @@
                     (*fp_gtk_color_selection_dialog_new)(NULL);
             }
             result = gtk3_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE];
             break;*/
         case COMBO_BOX:
-            if (init_result = (NULL == gtk3_widgets[_GTK_COMBO_BOX_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_COMBO_BOX_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_COMBO_BOX_TYPE] =
                     (*fp_gtk_combo_box_new)();
             }
             result = gtk3_widgets[_GTK_COMBO_BOX_TYPE];
             break;
         case COMBO_BOX_ARROW_BUTTON:
-            if (init_result =
-                    (NULL == gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE]))
+            init_result = 
+                (NULL == gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE] =
                      (*fp_gtk_toggle_button_new)();
             }
             result = gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE];
             break;
         case COMBO_BOX_TEXT_FIELD:
-            if (init_result =
-                    (NULL == gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE]))
+            init_result =
+                (NULL == gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE]);
+            if (init_result)
             {
                 result = gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE] =
                      (*fp_gtk_entry_new)();
             }
             result = gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE];
             break;
         case DESKTOP_ICON:
         case INTERNAL_FRAME_TITLE_PANE:
         case LABEL:
-            if (init_result = (NULL == gtk3_widgets[_GTK_LABEL_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_LABEL_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_LABEL_TYPE] =
                     (*fp_gtk_label_new)(NULL);
             }
             result = gtk3_widgets[_GTK_LABEL_TYPE];
             break;
         case DESKTOP_PANE:
         case PANEL:
         case ROOT_PANE:
-            if (init_result = (NULL == gtk3_widgets[_GTK_CONTAINER_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_CONTAINER_TYPE]);
+            if (init_result)
             {
                 /* There is no constructor for a container type.  I've
                  * chosen GtkFixed container since it has a default
                  * constructor.
                  */

@@ -983,29 +991,32 @@
             result = gtk3_widgets[_GTK_CONTAINER_TYPE];
             break;
         case EDITOR_PANE:
         case TEXT_AREA:
         case TEXT_PANE:
-            if (init_result = (NULL == gtk3_widgets[_GTK_TEXT_VIEW_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_TEXT_VIEW_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_TEXT_VIEW_TYPE] =
                     (*fp_gtk_text_view_new)();
             }
             result = gtk3_widgets[_GTK_TEXT_VIEW_TYPE];
             break;
         case FORMATTED_TEXT_FIELD:
         case PASSWORD_FIELD:
         case TEXT_FIELD:
-            if (init_result = (NULL == gtk3_widgets[_GTK_ENTRY_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_ENTRY_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_ENTRY_TYPE] =
                     (*fp_gtk_entry_new)();
             }
             result = gtk3_widgets[_GTK_ENTRY_TYPE];
             break;
         case HANDLE_BOX:
-            if (init_result = (NULL == gtk3_widgets[_GTK_HANDLE_BOX_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_HANDLE_BOX_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_HANDLE_BOX_TYPE] =
                     (*fp_gtk_handle_box_new)();
             }
             result = gtk3_widgets[_GTK_HANDLE_BOX_TYPE];

@@ -1013,138 +1024,154 @@
         case HSCROLL_BAR:
         case HSCROLL_BAR_BUTTON_LEFT:
         case HSCROLL_BAR_BUTTON_RIGHT:
         case HSCROLL_BAR_TRACK:
         case HSCROLL_BAR_THUMB:
-            if (init_result = (NULL == gtk3_widgets[_GTK_HSCROLLBAR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_HSCROLLBAR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_HSCROLLBAR_TYPE] =
                     (*fp_gtk_hscrollbar_new)(create_adjustment());
             }
             result = gtk3_widgets[_GTK_HSCROLLBAR_TYPE];
             break;
         case HSEPARATOR:
-            if (init_result = (NULL == gtk3_widgets[_GTK_HSEPARATOR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_HSEPARATOR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_HSEPARATOR_TYPE] =
                     (*fp_gtk_hseparator_new)();
             }
             result = gtk3_widgets[_GTK_HSEPARATOR_TYPE];
             break;
         case HSLIDER:
         case HSLIDER_THUMB:
         case HSLIDER_TRACK:
-            if (init_result = (NULL == gtk3_widgets[_GTK_HSCALE_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_HSCALE_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_HSCALE_TYPE] =
                     (*fp_gtk_scale_new)(GTK_ORIENTATION_HORIZONTAL, NULL);
             }
             result = gtk3_widgets[_GTK_HSCALE_TYPE];
             break;
         case HSPLIT_PANE_DIVIDER:
         case SPLIT_PANE:
-            if (init_result = (NULL == gtk3_widgets[_GTK_HPANED_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_HPANED_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_hpaned_new)();
             }
             result = gtk3_widgets[_GTK_HPANED_TYPE];
             break;
         case IMAGE:
-            if (init_result = (NULL == gtk3_widgets[_GTK_IMAGE_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_IMAGE_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_IMAGE_TYPE] = (*fp_gtk_image_new)();
             }
             result = gtk3_widgets[_GTK_IMAGE_TYPE];
             break;
         case INTERNAL_FRAME:
-            if (init_result = (NULL == gtk3_widgets[_GTK_WINDOW_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_WINDOW_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_WINDOW_TYPE] =
                     (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
             }
             result = gtk3_widgets[_GTK_WINDOW_TYPE];
             break;
         case TOOL_TIP:
-            if (init_result = (NULL == gtk3_widgets[_GTK_TOOLTIP_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_TOOLTIP_TYPE]);
+            if (init_result)
             {
                 result = (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
                 gtk3_widgets[_GTK_TOOLTIP_TYPE] = result;
             }
             result = gtk3_widgets[_GTK_TOOLTIP_TYPE];
             break;
         case LIST:
         case TABLE:
         case TREE:
         case TREE_CELL:
-            if (init_result = (NULL == gtk3_widgets[_GTK_TREE_VIEW_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_TREE_VIEW_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_TREE_VIEW_TYPE] =
                     (*fp_gtk_tree_view_new)();
             }
             result = gtk3_widgets[_GTK_TREE_VIEW_TYPE];
             break;
         case TITLED_BORDER:
-            if (init_result = (NULL == gtk3_widgets[_GTK_FRAME_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_FRAME_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_FRAME_TYPE] = fp_gtk_frame_new(NULL);
             }
             result = gtk3_widgets[_GTK_FRAME_TYPE];
             break;
         case POPUP_MENU:
-            if (init_result = (NULL == gtk3_widgets[_GTK_MENU_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_MENU_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_MENU_TYPE] =
                     (*fp_gtk_menu_new)();
             }
             result = gtk3_widgets[_GTK_MENU_TYPE];
             break;
         case MENU:
         case MENU_ITEM:
         case MENU_ITEM_ACCELERATOR:
-            if (init_result = (NULL == gtk3_widgets[_GTK_MENU_ITEM_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_MENU_ITEM_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_MENU_ITEM_TYPE] =
                     (*fp_gtk_menu_item_new)();
             }
             result = gtk3_widgets[_GTK_MENU_ITEM_TYPE];
             break;
         case MENU_BAR:
-            if (init_result = (NULL == gtk3_widgets[_GTK_MENU_BAR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_MENU_BAR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_MENU_BAR_TYPE] =
                     (*fp_gtk_menu_bar_new)();
             }
             result = gtk3_widgets[_GTK_MENU_BAR_TYPE];
             break;
         case COLOR_CHOOSER:
         case OPTION_PANE:
-            if (init_result = (NULL == gtk3_widgets[_GTK_DIALOG_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_DIALOG_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_DIALOG_TYPE] =
                     (*fp_gtk_dialog_new)();
             }
             result = gtk3_widgets[_GTK_DIALOG_TYPE];
             break;
         case POPUP_MENU_SEPARATOR:
-            if (init_result =
-                    (NULL == gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE]))
+            init_result =
+                    (NULL == gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE] =
                     (*fp_gtk_separator_menu_item_new)();
             }
             result = gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE];
             break;
         case HPROGRESS_BAR:
-            if (init_result = (NULL == gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE] =
                     (*fp_gtk_progress_bar_new)();
             }
             result = gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE];
             break;
         case VPROGRESS_BAR:
-            if (init_result = (NULL == gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE] =
                     (*fp_gtk_progress_bar_new)();
                 /*
                  * Vertical JProgressBars always go bottom-to-top,

@@ -1155,84 +1182,93 @@
                     GTK_PROGRESS_BOTTOM_TO_TOP);
             }
             result = gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE];
             break;
         case RADIO_BUTTON:
-            if (init_result = (NULL == gtk3_widgets[_GTK_RADIO_BUTTON_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_RADIO_BUTTON_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_RADIO_BUTTON_TYPE] =
                     (*fp_gtk_radio_button_new)(NULL);
             }
             result = gtk3_widgets[_GTK_RADIO_BUTTON_TYPE];
             break;
         case RADIO_BUTTON_MENU_ITEM:
-            if (init_result =
-                    (NULL == gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE]))
+            init_result =
+                    (NULL == gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE] =
                     (*fp_gtk_radio_menu_item_new)(NULL);
             }
             result = gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE];
             break;
         case SCROLL_PANE:
-            if (init_result =
-                    (NULL == gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE]))
+            init_result =
+                    (NULL == gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE] =
                     (*fp_gtk_scrolled_window_new)(NULL, NULL);
             }
             result = gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE];
             break;
         case SPINNER:
         case SPINNER_ARROW_BUTTON:
         case SPINNER_TEXT_FIELD:
-            if (init_result = (NULL == gtk3_widgets[_GTK_SPIN_BUTTON_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_SPIN_BUTTON_TYPE]);
+            if (init_result)
             {
                 result = gtk3_widgets[_GTK_SPIN_BUTTON_TYPE] =
                     (*fp_gtk_spin_button_new)(NULL, 0, 0);
             }
             result = gtk3_widgets[_GTK_SPIN_BUTTON_TYPE];
             break;
         case TABBED_PANE:
         case TABBED_PANE_TAB_AREA:
         case TABBED_PANE_CONTENT:
         case TABBED_PANE_TAB:
-            if (init_result = (NULL == gtk3_widgets[_GTK_NOTEBOOK_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_NOTEBOOK_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_NOTEBOOK_TYPE] =
                     (*fp_gtk_notebook_new)(NULL);
             }
             result = gtk3_widgets[_GTK_NOTEBOOK_TYPE];
             break;
         case TOGGLE_BUTTON:
-            if (init_result = (NULL == gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE] =
                     (*fp_gtk_toggle_button_new)(NULL);
             }
             result = gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE];
             break;
         case TOOL_BAR:
         case TOOL_BAR_DRAG_WINDOW:
-            if (init_result = (NULL == gtk3_widgets[_GTK_TOOLBAR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_TOOLBAR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_TOOLBAR_TYPE] =
                     (*fp_gtk_toolbar_new)(NULL);
             }
             result = gtk3_widgets[_GTK_TOOLBAR_TYPE];
             break;
         case TOOL_BAR_SEPARATOR:
-            if (init_result =
-                    (NULL == gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE]))
+            init_result =
+                    (NULL == gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE] =
                     (*fp_gtk_separator_tool_item_new)();
             }
             result = gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE];
             break;
         case VIEWPORT:
-            if (init_result = (NULL == gtk3_widgets[_GTK_VIEWPORT_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_VIEWPORT_TYPE]);
+            if (init_result)
             {
                 GtkAdjustment *adjustment = create_adjustment();
                 gtk3_widgets[_GTK_VIEWPORT_TYPE] =
                     (*fp_gtk_viewport_new)(adjustment, adjustment);
             }

@@ -1241,29 +1277,32 @@
         case VSCROLL_BAR:
         case VSCROLL_BAR_BUTTON_UP:
         case VSCROLL_BAR_BUTTON_DOWN:
         case VSCROLL_BAR_TRACK:
         case VSCROLL_BAR_THUMB:
-            if (init_result = (NULL == gtk3_widgets[_GTK_VSCROLLBAR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_VSCROLLBAR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_VSCROLLBAR_TYPE] =
                     (*fp_gtk_vscrollbar_new)(create_adjustment());
             }
             result = gtk3_widgets[_GTK_VSCROLLBAR_TYPE];
             break;
         case VSEPARATOR:
-            if (init_result = (NULL == gtk3_widgets[_GTK_VSEPARATOR_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_VSEPARATOR_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_VSEPARATOR_TYPE] =
                     (*fp_gtk_vseparator_new)();
             }
             result = gtk3_widgets[_GTK_VSEPARATOR_TYPE];
             break;
         case VSLIDER:
         case VSLIDER_THUMB:
         case VSLIDER_TRACK:
-            if (init_result = (NULL == gtk3_widgets[_GTK_VSCALE_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_VSCALE_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_VSCALE_TYPE] =
                     (*fp_gtk_scale_new)(GTK_ORIENTATION_VERTICAL, NULL);
             }
             result = gtk3_widgets[_GTK_VSCALE_TYPE];

@@ -1273,11 +1312,12 @@
              * this we set the "inverted" flag to get the Swing behavior.
              */
              fp_gtk_range_set_inverted((GtkRange*)result, TRUE);
             break;
         case VSPLIT_PANE_DIVIDER:
-            if (init_result = (NULL == gtk3_widgets[_GTK_VPANED_TYPE]))
+            init_result = (NULL == gtk3_widgets[_GTK_VPANED_TYPE]);
+            if (init_result)
             {
                 gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_vpaned_new)();
             }
             result = gtk3_widgets[_GTK_VPANED_TYPE];
             break;

@@ -1987,15 +2027,11 @@
 
 /*************************************************/
 static guint8 recode_color(gdouble channel)
 {
     guint16 result = (guint16)(channel * 65535);
-    if (result < 0) {
-        result = 0;
-    } else if (result > 65535) {
-        result = 65535;
-    }
+
     return (guint8)( result >> 8);
 }
 
 static GtkStateFlags gtk3_get_state_flags(GtkStateType state_type) {
     switch (state_type)
< prev index next >