~vish/ubuntu/maverick/pidgin/bug25979

« back to all changes in this revision

Viewing changes to pidgin/pidgincombobox.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-10-09 19:40:26 UTC
  • mfrom: (1.4.1 upstream) (46.1.10 karmic)
  • Revision ID: james.westby@ubuntu.com-20091009194026-wbqqh0bsbz19nx5q
Tags: 1:2.6.2-1ubuntu7
* Don't stick the buddy list window to all desktops as some
  window managers have trouble to properly unstick it (LP: #346840)
  - debian/patches/11_buddy_list_really_show.patch
* Always use default tray icon size on KDE (LP: #209440)
  - debian/patches/62_tray_icon_size_kde.patch
* Use scrollbars in the preferences dialog if the screen height is
  below 700 px instead of 600 px
  - debian/patches/60_1024x600_gtkprefs.c.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
/* While debugging this evil code, I have learned that
113
113
 * there are actually 4 modes to this widget, which can
114
114
 * be characterized as follows
115
 
 * 
 
115
 *
116
116
 * 1) menu mode, no child added
117
117
 *
118
118
 * tree_view -> NULL
127
127
 * popup_frame -> NULL
128
128
 *
129
129
 * 2) menu mode, child added
130
 
 * 
 
130
 *
131
131
 * tree_view -> NULL
132
 
 * cell_view -> NULL 
 
132
 * cell_view -> NULL
133
133
 * cell_view_frame -> NULL
134
134
 * button -> GtkToggleButton set_parent to combo
135
135
 * box -> NULL
140
140
 * popup_frame -> NULL
141
141
 *
142
142
 * 3) list mode, no child added
143
 
 * 
 
143
 *
144
144
 * tree_view -> GtkTreeView, child of popup_frame
145
145
 * cell_view -> GtkCellView, regular child
146
146
 * cell_view_frame -> GtkFrame, set parent to combo
164
164
 * popup_widget -> tree_view
165
165
 * popup_window -> GtkWindow
166
166
 * popup_frame -> GtkFrame, child of popup_window
167
 
 * 
 
167
 *
168
168
 */
169
169
 
170
170
enum {
285
285
                                                    gpointer          data);
286
286
 
287
287
/* list */
288
 
static void     gtk_combo_box_list_position        (GtkComboBox      *combo_box, 
289
 
                                                    gint             *x, 
290
 
                                                    gint             *y, 
 
288
static void     gtk_combo_box_list_position        (GtkComboBox      *combo_box,
 
289
                                                    gint             *x,
 
290
                                                    gint             *y,
291
291
                                                    gint             *width,
292
292
                                                    gint             *height);
293
293
 
641
641
  if (GTK_WIDGET_REALIZED (widget))
642
642
    {
643
643
      if (combo_box->priv->tree_view && combo_box->priv->cell_view)
644
 
        gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), 
 
644
        gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
645
645
                                            &widget->style->base[GTK_WIDGET_STATE (widget)]);
646
646
    }
647
647
 
694
694
  gtk_combo_box_check_appearance (combo_box);
695
695
 
696
696
  if (combo_box->priv->tree_view && combo_box->priv->cell_view)
697
 
    gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), 
 
697
    gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
698
698
                                        &widget->style->base[GTK_WIDGET_STATE (widget)]);
699
699
}
700
700
 
725
725
      GTK_BIN (container)->child = NULL;
726
726
      gtk_widget_queue_resize (GTK_WIDGET (container));
727
727
    }
728
 
  
 
728
 
729
729
  gtk_widget_set_parent (widget, GTK_WIDGET (container));
730
730
  GTK_BIN (container)->child = widget;
731
731
 
770
770
    appears_as_list = FALSE;
771
771
  else
772
772
    appears_as_list = TRUE;
773
 
  
 
773
 
774
774
  if (appears_as_list)
775
775
    gtk_combo_box_list_destroy (combo_box);
776
776
  else if (GTK_IS_MENU (combo_box->priv->popup_widget))
785
785
      combo_box->priv->cell_view = gtk_cell_view_new ();
786
786
      gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container));
787
787
      GTK_BIN (container)->child = combo_box->priv->cell_view;
788
 
      
 
788
 
789
789
      gtk_widget_show (combo_box->priv->cell_view);
790
790
      gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
791
791
                               combo_box->priv->model);
856
856
  g_signal_handlers_disconnect_by_func (menu,
857
857
                                        gtk_combo_box_menu_hide,
858
858
                                        combo_box);
859
 
  
 
859
 
860
860
  combo_box->priv->popup_widget = NULL;
861
861
}
862
862
 
940
940
  GdkScreen *screen;
941
941
  gint monitor_num;
942
942
  GdkRectangle monitor;
943
 
  
 
943
 
944
944
  /* FIXME: is using the size request here broken? */
945
945
   child = GTK_BIN (combo_box)->child;
946
 
   
 
946
 
947
947
   gdk_window_get_origin (child->window, &sx, &sy);
948
 
   
 
948
 
949
949
   if (GTK_WIDGET_NO_WINDOW (child))
950
950
      {
951
951
        sx += child->allocation.x;
961
961
   *y = sy;
962
962
 
963
963
  screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
964
 
  monitor_num = gdk_screen_get_monitor_at_window (screen, 
 
964
  monitor_num = gdk_screen_get_monitor_at_window (screen,
965
965
                                                  GTK_WIDGET (combo_box)->window);
966
966
  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
967
 
  
 
967
 
968
968
  if (*x < monitor.x)
969
969
    *x = monitor.x;
970
970
  else if (*x + req.width > monitor.x + monitor.width)
971
971
    *x = monitor.x + monitor.width - req.width;
972
 
  
 
972
 
973
973
  if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
974
974
    *y += child->allocation.height;
975
975
  else if (*y - monitor.y >= req.height)
976
976
    *y -= req.height;
977
 
  else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y) 
 
977
  else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y)
978
978
    *y += child->allocation.height;
979
979
  else
980
980
    *y -= req.height;
1001
1001
  gint menu_width;
1002
1002
 
1003
1003
  g_return_if_fail (GTK_IS_COMBO_BOX (user_data));
1004
 
  
 
1004
 
1005
1005
  combo_box = GTK_COMBO_BOX (user_data);
1006
1006
  widget = GTK_WIDGET (combo_box);
1007
1007
 
1042
1042
 
1043
1043
  /* Clamp the position on screen */
1044
1044
  screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
1045
 
  
 
1045
 
1046
1046
  if (menu_xpos < 0)
1047
1047
    menu_xpos = 0;
1048
1048
  else if ((menu_xpos + menu_width) > screen_width)
1066
1066
 
1067
1067
  combo_box = GTK_COMBO_BOX (user_data);
1068
1068
 
1069
 
  if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL)    
 
1069
  if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL)
1070
1070
    gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
1071
1071
  else
1072
1072
    {
1073
1073
      menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
1074
1074
      if (menu_item)
1075
 
        gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget), 
 
1075
        gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget),
1076
1076
                                    menu_item);
1077
1077
 
1078
1078
      gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
1082
1082
#endif /* Gtk 2.2 */
1083
1083
 
1084
1084
static void
1085
 
gtk_combo_box_list_position (GtkComboBox *combo_box, 
1086
 
                             gint        *x, 
1087
 
                             gint        *y, 
 
1085
gtk_combo_box_list_position (GtkComboBox *combo_box,
 
1086
                             gint        *x,
 
1087
                             gint        *y,
1088
1088
                             gint        *width,
1089
1089
                             gint        *height)
1090
1090
{
1095
1095
  gint monitor_num;
1096
1096
  GdkRectangle monitor;
1097
1097
#endif
1098
 
  
 
1098
 
1099
1099
  sample = GTK_BIN (combo_box)->child;
1100
1100
 
1101
1101
  *width = sample->allocation.width;
1117
1117
      *x += sample->allocation.x;
1118
1118
      *y += sample->allocation.y;
1119
1119
    }
1120
 
  
 
1120
 
1121
1121
#if GTK_CHECK_VERSION(2,2,0)
1122
1122
  screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
1123
 
  monitor_num = gdk_screen_get_monitor_at_window (screen, 
 
1123
  monitor_num = gdk_screen_get_monitor_at_window (screen,
1124
1124
                                                  GTK_WIDGET (combo_box)->window);
1125
1125
  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
1126
 
  
 
1126
 
1127
1127
  if (*x < monitor.x)
1128
1128
    *x = monitor.x;
1129
1129
  else if (*x + *width > monitor.x + monitor.width)
1130
1130
    *x = monitor.x + monitor.width - *width;
1131
 
  
 
1131
 
1132
1132
  if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
1133
1133
    *y += sample->allocation.height;
1134
1134
  else
1135
1135
    *y -= *height;
1136
1136
#endif /* Gtk 2.2 */
1137
 
 
1137
}
1138
1138
 
1139
1139
/**
1140
1140
 * gtk_combo_box_popup:
1141
1141
 * @combo_box: a #GtkComboBox
1142
 
 * 
1143
 
 * Pops up the menu or dropdown list of @combo_box. 
 
1142
 *
 
1143
 * Pops up the menu or dropdown list of @combo_box.
1144
1144
 *
1145
1145
 * This function is mostly intended for use by accessibility technologies;
1146
1146
 * applications should have little use for it.
1151
1151
gtk_combo_box_popup (GtkComboBox *combo_box)
1152
1152
{
1153
1153
  gint x, y, width, height;
1154
 
  
 
1154
 
1155
1155
  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
1156
1156
 
1157
1157
  if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget))
1172
1172
          gtk_widget_set_size_request (combo_box->priv->popup_widget,
1173
1173
                                       MAX (width, requisition.width), -1);
1174
1174
        }
1175
 
      
 
1175
 
1176
1176
      gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
1177
1177
                      NULL, NULL,
1178
1178
#if GTK_CHECK_VERSION(2,2,0)
1187
1187
  gtk_widget_show_all (combo_box->priv->popup_frame);
1188
1188
  gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
1189
1189
 
1190
 
  gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1);  
 
1190
  gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1);
1191
1191
  gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y);
1192
1192
 
1193
1193
  /* popup */
1217
1217
/**
1218
1218
 * gtk_combo_box_popdown:
1219
1219
 * @combo_box: a #GtkComboBox
1220
 
 * 
 
1220
 *
1221
1221
 * Hides the menu or dropdown list of @combo_box.
1222
1222
 *
1223
1223
 * This function is mostly intended for use by accessibility technologies;
1305
1305
      GtkRequisition req;
1306
1306
 
1307
1307
      if (combo_box->priv->cell_view)
1308
 
        gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), 
 
1308
        gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view),
1309
1309
                                       path, &req);
1310
1310
      else
1311
1311
        req.width = 0;
1335
1335
  bin_req.width = MAX (bin_req.width, combo_box->priv->width);
1336
1336
 
1337
1337
  gtk_combo_box_check_appearance (combo_box);
1338
 
      
 
1338
 
1339
1339
  if (!combo_box->priv->tree_view)
1340
1340
    {
1341
1341
      /* menu mode */
1454
1454
          if (is_rtl)
1455
1455
            {
1456
1456
              child.x += req.width;
1457
 
              child.width = MAX(1, allocation->x + allocation->width 
 
1457
              child.width = MAX(1, allocation->x + allocation->width
1458
1458
                - (border_width + 1 + xthickness + 2) - child.x);
1459
1459
            }
1460
 
          else 
 
1460
          else
1461
1461
            {
1462
1462
              child.width = child.x;
1463
1463
              child.x = allocation->x + border_width + 1 + xthickness + 2;
1623
1623
  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
1624
1624
  gint index;
1625
1625
  gint items;
1626
 
    
 
1626
 
1627
1627
  index = gtk_combo_box_get_active (combo_box);
1628
1628
 
1629
1629
  if (index != -1)
1630
1630
    {
1631
1631
      items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
1632
 
      
 
1632
 
1633
1633
      if (event->direction == GDK_SCROLL_UP)
1634
1634
        index--;
1635
 
      else 
 
1635
      else
1636
1636
        index++;
1637
1637
 
1638
1638
      gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1));
1694
1694
                             GTK_BIN (combo_box)->child->parent);
1695
1695
 
1696
1696
      combo_box->priv->box = gtk_hbox_new (FALSE, 0);
1697
 
      gtk_container_add (GTK_CONTAINER (combo_box->priv->button), 
 
1697
      gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
1698
1698
                         combo_box->priv->box);
1699
1699
 
1700
1700
      combo_box->priv->separator = gtk_vseparator_new ();
1701
 
      gtk_container_add (GTK_CONTAINER (combo_box->priv->box), 
 
1701
      gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
1702
1702
                         combo_box->priv->separator);
1703
1703
 
1704
1704
      combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
1705
 
      gtk_container_add (GTK_CONTAINER (combo_box->priv->box), 
 
1705
      gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
1706
1706
                         combo_box->priv->arrow);
1707
1707
 
1708
1708
      gtk_widget_show_all (combo_box->priv->button);
1792
1792
 
1793
1793
  /* unparent will remove our latest ref */
1794
1794
  gtk_widget_unparent (combo_box->priv->button);
1795
 
  
 
1795
 
1796
1796
  combo_box->priv->box = NULL;
1797
1797
  combo_box->priv->button = NULL;
1798
1798
  combo_box->priv->arrow = NULL;
1895
1895
  item = nth->data;
1896
1896
  if (nth->prev)
1897
1897
    last = nth->prev->data;
1898
 
  else 
 
1898
  else
1899
1899
    last = NULL;
1900
1900
  g_list_free (list);
1901
1901
 
1902
1902
  gtk_combo_box_item_get_size (combo_box, index, &cols, &rows);
1903
 
      
 
1903
 
1904
1904
   if (combo_box->priv->col_column == -1 &&
1905
1905
      combo_box->priv->row_column == -1 &&
1906
1906
      last)
1907
1907
    {
1908
 
      gtk_container_child_get (GTK_CONTAINER (menu), 
 
1908
      gtk_container_child_get (GTK_CONTAINER (menu),
1909
1909
                               last,
1910
1910
                               "right_attach", &current_col,
1911
1911
                               "top_attach", &current_row,
1926
1926
              current_col = 0;
1927
1927
              current_row++;
1928
1928
            }
1929
 
          
 
1929
 
1930
1930
          if (!menu_occupied (GTK_MENU (menu),
1931
1931
                              current_col, current_col + cols,
1932
1932
                              current_row, current_row + rows))
1933
1933
            break;
1934
 
          
 
1934
 
1935
1935
          current_col++;
1936
1936
        }
1937
1937
    }
1949
1949
  GtkWidget *menu;
1950
1950
 
1951
1951
  menu = combo_box->priv->popup_widget;
1952
 
  
 
1952
 
1953
1953
  /* do nothing unless we are in menu style and realized */
1954
1954
  if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu))
1955
1955
    return;
1956
 
  
 
1956
 
1957
1957
  /* get rid of all children */
1958
1958
  list = gtk_container_get_children (GTK_CONTAINER (menu));
1959
 
  
 
1959
 
1960
1960
  for (j = g_list_last (list); j; j = j->prev)
1961
1961
    gtk_container_remove (GTK_CONTAINER (menu), j->data);
1962
 
  
 
1962
 
1963
1963
  g_list_free (list);
1964
 
      
 
1964
 
1965
1965
  /* and relayout */
1966
1966
  gtk_combo_box_menu_fill (combo_box);
1967
1967
}
1980
1980
  if (event->type == GDK_BUTTON_PRESS && event->button == 1)
1981
1981
    {
1982
1982
      combo_box->priv->popup_in_progress = TRUE;
1983
 
      
 
1983
 
1984
1984
      gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget),
1985
1985
                           combo_box->priv->active_item);
1986
1986
 
2053
2053
 
2054
2054
  if (!combo_box->priv->tree_view)
2055
2055
    gtk_combo_box_menu_row_deleted (model, path, user_data);
2056
 
  
 
2056
 
2057
2057
  if (index == combo_box->priv->active_item)
2058
2058
    {
2059
2059
      gint items = gtk_tree_model_iter_n_children (model, NULL);
2090
2090
  if (!combo_box->priv->tree_view)
2091
2091
    gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data);
2092
2092
}
2093
 
                                                    
 
2093
 
2094
2094
static void
2095
2095
gtk_combo_box_model_row_changed (GtkTreeModel     *model,
2096
2096
                                 GtkTreePath      *path,
2103
2103
  if (index == combo_box->priv->active_item &&
2104
2104
      combo_box->priv->cell_view)
2105
2105
    gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view));
2106
 
  
 
2106
 
2107
2107
  if (combo_box->priv->tree_view)
2108
2108
    gtk_combo_box_list_row_changed (model, path, iter, user_data);
2109
2109
  else
2174
2174
 
2175
2175
  gtk_combo_box_relayout (combo_box);
2176
2176
}
2177
 
                                    
 
2177
 
2178
2178
static void
2179
2179
gtk_combo_box_menu_row_changed (GtkTreeModel *model,
2180
2180
                                GtkTreePath  *path,
2238
2238
      gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->cell_view_frame),
2239
2239
                                 GTK_SHADOW_IN);
2240
2240
 
2241
 
      gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), 
 
2241
      gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
2242
2242
                                          &GTK_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]);
2243
2243
 
2244
2244
      combo_box->priv->box = gtk_event_box_new ();
2245
2245
      /*
2246
 
      gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box), 
 
2246
      gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box),
2247
2247
                                        FALSE);
2248
2248
      */
2249
2249
 
2253
2253
      gtk_widget_show_all (combo_box->priv->cell_view_frame);
2254
2254
 
2255
2255
      g_signal_connect (combo_box->priv->box, "button_press_event",
2256
 
                        G_CALLBACK (gtk_combo_box_list_button_pressed), 
 
2256
                        G_CALLBACK (gtk_combo_box_list_button_pressed),
2257
2257
                        combo_box);
2258
2258
    }
2259
2259
 
2269
2269
  if (combo_box->priv->model)
2270
2270
    gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view),
2271
2271
                             combo_box->priv->model);
2272
 
    
 
2272
 
2273
2273
  g_signal_connect (combo_box->priv->tree_view, "button_press_event",
2274
2274
                    G_CALLBACK (gtk_combo_box_list_button_pressed),
2275
2275
                    combo_box);
2494
2494
  if (combo_box->priv->model)
2495
2495
    items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
2496
2496
 
2497
 
  if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) && 
 
2497
  if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) &&
2498
2498
      state == GDK_MOD1_MASK)
2499
2499
    {
2500
2500
      gtk_combo_box_popup (combo_box);
2502
2502
      return TRUE;
2503
2503
    }
2504
2504
 
2505
 
  switch (event->keyval) 
 
2505
  switch (event->keyval)
2506
2506
    {
2507
2507
    case GDK_Down:
2508
2508
    case GDK_KP_Down:
2514
2514
      break;
2515
2515
    case GDK_Page_Up:
2516
2516
    case GDK_KP_Page_Up:
2517
 
    case GDK_Home: 
 
2517
    case GDK_Home:
2518
2518
    case GDK_KP_Home:
2519
2519
      new_index = 0;
2520
2520
      break;
2521
2521
    case GDK_Page_Down:
2522
2522
    case GDK_KP_Page_Down:
2523
 
    case GDK_End: 
 
2523
    case GDK_End:
2524
2524
    case GDK_KP_End:
2525
2525
      new_index = items - 1;
2526
2526
      break;
2527
2527
    default:
2528
2528
      return FALSE;
2529
2529
    }
2530
 
      
 
2530
 
2531
2531
  if (items > 0)
2532
2532
    gtk_combo_box_set_active (combo_box, CLAMP (new_index, 0, items - 1));
2533
2533
 
2542
2542
  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
2543
2543
  guint state = event->state & gtk_accelerator_get_default_mod_mask ();
2544
2544
 
2545
 
  if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && 
 
2545
  if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
2546
2546
      state == GDK_MOD1_MASK)
2547
2547
    {
2548
2548
      gtk_combo_box_popdown (combo_box);
2549
2549
 
2550
2550
      return TRUE;
2551
2551
    }
2552
 
  
 
2552
 
2553
2553
  return FALSE;
2554
2554
}
2555
2555
 
2562
2562
  guint state = event->state & gtk_accelerator_get_default_mod_mask ();
2563
2563
 
2564
2564
  if (event->keyval == GDK_Escape ||
2565
 
      ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && 
 
2565
      ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
2566
2566
       state == GDK_MOD1_MASK))
2567
2567
    {
2568
2568
      /* reset active item -- this is incredibly lame and ugly */
2569
2569
      gtk_combo_box_set_active (combo_box,
2570
2570
                                gtk_combo_box_get_active (combo_box));
2571
 
      
 
2571
 
2572
2572
      gtk_combo_box_popdown (combo_box);
2573
 
      
 
2573
 
2574
2574
      return TRUE;
2575
2575
    }
2576
 
    
 
2576
 
2577
2577
  if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter ||
2578
 
      event->keyval == GDK_space || event->keyval == GDK_KP_Space) 
 
2578
      event->keyval == GDK_space || event->keyval == GDK_KP_Space)
2579
2579
  {
2580
2580
    gboolean ret = FALSE;
2581
2581
    GtkTreeIter iter;
2582
2582
    GtkTreeModel *model = NULL;
2583
 
    
 
2583
 
2584
2584
    if (combo_box->priv->model)
2585
2585
      {
2586
2586
        GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view));
2587
 
    
 
2587
 
2588
2588
        ret = gtk_tree_selection_get_selected (sel, &model, &iter);
2589
2589
      }
2590
2590
    if (ret)
2591
2591
      {
2592
2592
        GtkTreePath *path;
2593
 
        
 
2593
 
2594
2594
        path = gtk_tree_model_get_path (model, &iter);
2595
2595
        if (path)
2596
2596
          {
2600
2600
      }
2601
2601
 
2602
2602
    gtk_combo_box_popdown (combo_box);
2603
 
    
 
2603
 
2604
2604
    return TRUE;
2605
2605
  }
2606
2606
 
2620
2620
 
2621
2621
  if (width > combo_box->priv->width)
2622
2622
    {
2623
 
      if (combo_box->priv->cell_view) 
 
2623
      if (combo_box->priv->cell_view)
2624
2624
        {
2625
2625
          gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
2626
2626
          gtk_widget_queue_resize (combo_box->priv->cell_view);
2742
2742
  GtkWidget *menu;
2743
2743
  GtkComboBox *combo_box;
2744
2744
  GSList *i;
2745
 
  
 
2745
 
2746
2746
  g_return_if_fail (GTK_IS_COMBO_BOX (layout));
2747
2747
 
2748
2748
  combo_box = GTK_COMBO_BOX (layout);
2749
 
 
 
2749
 
2750
2750
  if (combo_box->priv->cell_view)
2751
2751
    gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view));
2752
2752
 
3082
3082
 
3083
3083
      gtk_combo_box_check_appearance (combo_box);
3084
3084
      gtk_combo_box_relayout (combo_box);
3085
 
      
 
3085
 
3086
3086
      g_object_notify (G_OBJECT (combo_box), "wrap_width");
3087
3087
    }
3088
3088
}
3112
3112
  if (row_span != combo_box->priv->row_column)
3113
3113
    {
3114
3114
      combo_box->priv->row_column = row_span;
3115
 
      
 
3115
 
3116
3116
      gtk_combo_box_relayout (combo_box);
3117
 
 
 
3117
 
3118
3118
      g_object_notify (G_OBJECT (combo_box), "row_span_column");
3119
3119
    }
3120
3120
}
3144
3144
  if (column_span != combo_box->priv->col_column)
3145
3145
    {
3146
3146
      combo_box->priv->col_column = column_span;
3147
 
      
 
3147
 
3148
3148
      gtk_combo_box_relayout (combo_box);
3149
3149
 
3150
3150
      g_object_notify (G_OBJECT (combo_box), "column_span_column");
3191
3191
 
3192
3192
  if (combo_box->priv->active_item == index_)
3193
3193
    return;
3194
 
  
 
3194
 
3195
3195
  gtk_combo_box_set_active_internal (combo_box, index_);
3196
3196
}
3197
3197
 
3252
3252
 * gtk_combo_box_get_active_iter:
3253
3253
 * @combo_box: A #GtkComboBox
3254
3254
 * @iter: The uninitialized #GtkTreeIter.
3255
 
 * 
 
3255
 *
3256
3256
 * Sets @iter to point to the current active item, if it exists.
3257
 
 * 
 
3257
 *
3258
3258
 * Return value: %TRUE, if @iter was set
3259
3259
 *
3260
3260
 * Since: 2.4
3293
3293
 * gtk_combo_box_set_active_iter:
3294
3294
 * @combo_box: A #GtkComboBox
3295
3295
 * @iter: The #GtkTreeIter.
3296
 
 * 
3297
 
 * Sets the current active item to be the one referenced by @iter. 
 
3296
 *
 
3297
 * Sets the current active item to be the one referenced by @iter.
3298
3298
 * @iter must correspond to a path of depth one.
3299
 
 * 
 
3299
 *
3300
3300
 * Since: 2.4
3301
3301
 **/
3302
3302
void
3310
3310
  path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter);
3311
3311
  g_return_if_fail (path != NULL);
3312
3312
  g_return_if_fail (gtk_tree_path_get_depth (path) == 1);
3313
 
  
 
3313
 
3314
3314
  gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]);
3315
3315
  gtk_tree_path_free (path);
3316
3316
}
3320
3320
 * @combo_box: A #GtkComboBox.
3321
3321
 * @model: A #GtkTreeModel.
3322
3322
 *
3323
 
 * Sets the model used by @combo_box to be @model. Will unset a previously set 
 
3323
 * Sets the model used by @combo_box to be @model. Will unset a previously set
3324
3324
 * model (if applicable). If @model is %NULL, then it will unset the model.
3325
 
 * 
3326
 
 * Note that this function does not clear the cell renderers, you have to 
3327
 
 * call gtk_combo_box_cell_layout_clear() yourself if you need to set up 
 
3325
 *
 
3326
 * Note that this function does not clear the cell renderers, you have to
 
3327
 * call gtk_combo_box_cell_layout_clear() yourself if you need to set up
3328
3328
 * different cell renderers for the new model.
3329
3329
 *
3330
3330
 * Since: 2.4
3345
3345
 
3346
3346
  if (model == combo_box->priv->model)
3347
3347
    return;
3348
 
  
 
3348
 
3349
3349
  if (combo_box->priv->model)
3350
3350
    gtk_combo_box_unset_model (combo_box);
3351
3351
 
3368
3368
    g_signal_connect (combo_box->priv->model, "row_changed",
3369
3369
                      G_CALLBACK (gtk_combo_box_model_row_changed),
3370
3370
                      combo_box);
3371
 
      
 
3371
 
3372
3372
  if (combo_box->priv->tree_view)
3373
3373
    {
3374
3374
      /* list mode */
3574
3574
{
3575
3575
  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
3576
3576
 
3577
 
  gtk_combo_box_popdown (combo_box); 
 
3577
  gtk_combo_box_popdown (combo_box);
3578
3578
 
3579
3579
  combo_box->priv->destroying = 1;
3580
3580
 
3589
3589
{
3590
3590
  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
3591
3591
  GSList *i;
3592
 
  
 
3592
 
3593
3593
  if (GTK_IS_MENU (combo_box->priv->popup_widget))
3594
3594
    {
3595
3595
      gtk_combo_box_menu_destroy (combo_box);
3596
3596
      gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
3597
3597
      combo_box->priv->popup_widget = NULL;
3598
3598
    }
3599
 
  
 
3599
 
3600
3600
  if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
3601
3601
    gtk_combo_box_list_destroy (combo_box);
3602
3602
 
3655
3655
{
3656
3656
  GObject *object = G_OBJECT (child);
3657
3657
  AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
3658
 
                                                                                                   
 
3658
 
3659
3659
  if (!ai)
3660
3660
    {
3661
3661
      ai = g_new0 (AttachInfo, 1);
3662
3662
      g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free);
3663
3663
    }
3664
 
                                                                                                   
 
3664
 
3665
3665
  return ai;
3666
3666
}
3667
3667
 
3693
3693
                 guint      bottom_attach)
3694
3694
{
3695
3695
  GtkMenuShell *menu_shell;
3696
 
  
 
3696
 
3697
3697
  g_return_if_fail (GTK_IS_MENU (menu));
3698
3698
  g_return_if_fail (GTK_IS_MENU_ITEM (child));
3699
 
  g_return_if_fail (child->parent == NULL || 
 
3699
  g_return_if_fail (child->parent == NULL ||
3700
3700
                    child->parent == GTK_WIDGET (menu));
3701
3701
  g_return_if_fail (left_attach < right_attach);
3702
3702
  g_return_if_fail (top_attach < bottom_attach);
3703
3703
 
3704
3704
  menu_shell = GTK_MENU_SHELL (menu);
3705
 
  
 
3705
 
3706
3706
  if (!child->parent)
3707
3707
    {
3708
3708
      AttachInfo *ai = get_attach_info (child);
3709
 
      
 
3709
 
3710
3710
      ai->left_attach = left_attach;
3711
3711
      ai->right_attach = right_attach;
3712
3712
      ai->top_attach = top_attach;
3713
3713
      ai->bottom_attach = bottom_attach;
3714
 
      
 
3714
 
3715
3715
      menu_shell->children = g_list_append (menu_shell->children, child);
3716
3716
 
3717
3717
      gtk_widget_set_parent (child, GTK_WIDGET (menu));
3741
3741
  /* g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL); */
3742
3742
 
3743
3743
  if (gtk_combo_box_get_active_iter (combo_box, &iter))
3744
 
    gtk_tree_model_get (gtk_combo_box_get_model(combo_box), &iter, 
 
3744
    gtk_tree_model_get (gtk_combo_box_get_model(combo_box), &iter,
3745
3745
                        0, &text, -1);
3746
3746
  return text;
3747
3747
}