diff options
Diffstat (limited to 'libgtk_kylix')
| -rw-r--r-- | libgtk_kylix/GTKControls.pas | 16 | ||||
| -rw-r--r-- | libgtk_kylix/GTKForms.pas | 28 | ||||
| -rw-r--r-- | libgtk_kylix/GTKMenus.pas | 9 | ||||
| -rw-r--r-- | libgtk_kylix/GTKView.pas | 100 |
4 files changed, 30 insertions, 123 deletions
diff --git a/libgtk_kylix/GTKControls.pas b/libgtk_kylix/GTKControls.pas index 35719a8..ceafe18 100644 --- a/libgtk_kylix/GTKControls.pas +++ b/libgtk_kylix/GTKControls.pas @@ -469,24 +469,14 @@ var TooltipsData : PGtkTooltipsData; begin text := nil; Result := ''; - if Application.GTKVersion_2_12_0_Up then begin - g_object_get(FWidget, 'tooltip-text', @text, nil); - if text <> nil then Result := string(text); - end else begin - TooltipsData := gtk_tooltips_data_get(FWidget); - if Assigned(TooltipsData) then Result := PgcharToString(TooltipsData^.tip_text); - end; + g_object_get(FWidget, 'tooltip-text', @text, nil); + if text <> nil then Result := string(text); end; procedure TGTKControl.SetTooltip(Value: string); var FParentForm : TCustomGTKForm; begin - if Application.GTKVersion_2_12_0_Up then - g_object_set(FWidget, 'tooltip-text', PChar(Value), nil) - else begin - FParentForm := GetParentForm(Self); - if FParentForm <> nil then gtk_tooltips_set_tip(FParentForm.Tooltips.FObject, FWidget, StringToPgchar(Value), nil); - end; + g_object_set(FWidget, 'tooltip-text', PChar(Value), nil) end; procedure TGTKControl.SetFocus; diff --git a/libgtk_kylix/GTKForms.pas b/libgtk_kylix/GTKForms.pas index e35357f..0224825 100644 --- a/libgtk_kylix/GTKForms.pas +++ b/libgtk_kylix/GTKForms.pas @@ -178,7 +178,7 @@ type // Some basic types FTerminated: Boolean; FOnException: TExceptionEvent; FMainForm: TCustomGTKForm; - FMainFormSet, FGTK205Up, FGTK220Up, FGTK240Up, FGTK260Up, FGTK280Up, FGTK212Up: Boolean; + FMainFormSet: Boolean; FThreadID: __pthread_t; procedure Quit; protected @@ -205,12 +205,6 @@ type // Some basic types property Terminated: Boolean read FTerminated; property OnException: TExceptionEvent read FOnException write FOnException; published - property GTKVersion_2_0_5_Up: boolean read FGTK205Up; - property GTKVersion_2_2_0_Up: boolean read FGTK220Up; - property GTKVersion_2_4_0_Up: boolean read FGTK240Up; - property GTKVersion_2_6_0_Up: boolean read FGTK260Up; - property GTKVersion_2_8_0_Up: boolean read FGTK280Up; - property GTKVersion_2_12_0_Up: boolean read FGTK212Up; property ThreadID: __pthread_t read FThreadID; end; @@ -547,7 +541,6 @@ procedure TGTKApplication.CreateHandle; var I: Integer; Temp: string; - Ver : Pchar; begin Argc := ParamCount + 1; Argv := AllocMem((Argc + 1) * SizeOf(PChar)); @@ -563,26 +556,9 @@ begin PCharArray(Argv^)[Argc] := nil; {$R+} - // Check for correct version of GTK+ library - Ver := gtk_check_version(2, 12, 0); - FGTK212Up := Ver = nil; - if not FGTK212Up then Ver := gtk_check_version(2, 8, 0); - FGTK280Up := Ver = nil; - if not FGTK280Up then Ver := gtk_check_version(2, 6, 0); - FGTK260Up := Ver = nil; - if not FGTK260Up then Ver := gtk_check_version(2, 4, 0); - FGTK240Up := Ver = nil; - if not FGTK240Up then Ver := gtk_check_version(2, 2, 0); - FGTK220Up := Ver = nil; - if not FGTK220Up then Ver := gtk_check_version(2, 0, 5); - FGTK205Up := Ver = nil; - if not FGTK220Up then WriteLn('Warning: Your version of GTK+ is old and some workarounds has been activated. It is recommended to update GTK libraries at least to 2.2.0'); - if Ver <> nil then Ver := gtk_check_version(2, 0, 0); - if Ver <> nil then WriteLn('Warning: There might be some problems with GTK+ library or version conflict.'); - // Init threads my_g_thread_init(nil); - + (* ATTENTION: do not call gdk_threads_init(), it causes deadlocks and we don't really need it *) // gdk_threads_init; diff --git a/libgtk_kylix/GTKMenus.pas b/libgtk_kylix/GTKMenus.pas index 2534f4c..bf2c095 100644 --- a/libgtk_kylix/GTKMenus.pas +++ b/libgtk_kylix/GTKMenus.pas @@ -362,13 +362,8 @@ function TGTKMenuItem.GetTornOff: boolean; var b: gboolean; begin b := False; - if Application.GTKVersion_2_6_0_Up then begin - if FItemType = itTearOff then g_object_get(FWidget, 'tearoff-state', @b, nil) else - if Assigned(FMenu) and (Count > 0) then g_object_get(FMenu, 'tearoff-state', @b, nil); - end else begin - if FItemType = itTearOff then b := Boolean(torn_off(PGTKTearOffMenuItem(FWidget)^)) else - if Assigned(FMenu) and (Count > 0) then b := Boolean(torn_off(PGTKMenu(FMenu)^)); - end; + if FItemType = itTearOff then g_object_get(FWidget, 'tearoff-state', @b, nil) else + if Assigned(FMenu) and (Count > 0) then g_object_get(FMenu, 'tearoff-state', @b, nil); Result := b; end; diff --git a/libgtk_kylix/GTKView.pas b/libgtk_kylix/GTKView.pas index db1dc93..3b46fad 100644 --- a/libgtk_kylix/GTKView.pas +++ b/libgtk_kylix/GTKView.pas @@ -442,24 +442,12 @@ var Path: PGtkTreePath; Iter: TGtkTreeIter; begin Result := Index; - if Application.GTKVersion_2_0_5_Up then begin - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(Index))); - if not Assigned(Path) then Exit; - if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_child_path_to_path(FTreeModelSort, Path); - if not Assigned(Path) then Exit; - Result := gtk_tree_path_get_indices(Path)^; - gtk_tree_path_free(Path); - end else - if Assigned(FToSortedConvFunc) then Result := FToSortedConvFunc(Self, Index) else begin - gtk_tree_model_get_iter_from_string(FTreeModel, @Iter, PChar(IntToStr(Index))); -// gtk_tree_model_sort_convert_child_iter_to_iter(FTreeModelSort, @NewIter, @Iter); - Path := gtk_tree_model_get_path(FTreeModel, @Iter); - if not Assigned(Path) then Exit; - if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_child_path_to_path(FTreeModelSort, Path); - if not Assigned(Path) then Exit; - Result := StrToIntDef(String(gtk_tree_path_to_string(Path)), Index); - gtk_tree_path_free(Path); - end; + Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(Index))); + if not Assigned(Path) then Exit; + if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_child_path_to_path(FTreeModelSort, Path); + if not Assigned(Path) then Exit; + Result := gtk_tree_path_get_indices(Path)^; + gtk_tree_path_free(Path); end; function TGTKView.ConvertFromSorted(Index: integer): integer; @@ -467,24 +455,12 @@ var Path: PGtkTreePath; Iter: TGtkTreeIter; begin Result := Index; - if Application.GTKVersion_2_0_5_Up then begin - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(Index))); - if not Assigned(Path) then Exit; - if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_path_to_child_path(FTreeModelSort, Path); - if not Assigned(Path) then Exit; - Result := gtk_tree_path_get_indices(Path)^; - gtk_tree_path_free(Path); - end else - if Assigned(FFromSortedConvFunc) then Result := FFromSortedConvFunc(Self, Index) else begin - gtk_tree_model_get_iter_from_string(FTreeModel, @Iter, PChar(IntToStr(Index))); -// gtk_tree_model_sort_convert_child_iter_to_iter(FTreeModelSort, @NewIter, @Iter); - Path := gtk_tree_model_get_path(FTreeModel, @Iter); - if not Assigned(Path) then Exit; - if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_path_to_child_path(FTreeModelSort, Path); - if not Assigned(Path) then Exit; - Result := StrToIntDef(String(gtk_tree_path_to_string(Path)), Index); - gtk_tree_path_free(Path); - end; + Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(Index))); + if not Assigned(Path) then Exit; + if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_path_to_child_path(FTreeModelSort, Path); + if not Assigned(Path) then Exit; + Result := gtk_tree_path_get_indices(Path)^; + gtk_tree_path_free(Path); end; procedure CellDataFunc(tree_column : PGtkTreeViewColumn; cell : PGtkCellRenderer; tree_model : PGtkTreeModel; iter : PGtkTreeIter; data : gpointer); cdecl; @@ -522,8 +498,7 @@ begin Item := nil; if Assigned(arg1) then begin TGTKListView(user_data).ConvertPathToChild(arg1); - if Application.GTKVersion_2_0_5_Up then AIndex := gtk_tree_path_get_indices(arg1)^ - else AIndex := StrToIntDef(String(gtk_tree_path_to_string(arg1)), 0); + AIndex := gtk_tree_path_get_indices(arg1)^; Item := TGTKListView(user_data).Items[AIndex]; Item.FIndex := AIndex; end; @@ -562,39 +537,20 @@ begin end; function TGTKListView.GetSelected: TGTKListItem; -var Iter{, NewIter}: TGtkTreeIter; +var Iter: TGtkTreeIter; Path: PGtkTreePath; AIndex: integer; i: integer; begin Result := nil; Path := nil; - if not Application.GTKVersion_2_0_5_Up then begin - for i := 0 to Items.Count - 1 do begin - Path := gtk_tree_path_new_from_string(PChar(IntToStr(i))); - if gtk_tree_selection_path_is_selected(gtk_tree_view_get_selection(PGtkTreeView(FWidget)), Path) then Break else -// WriteLn('Index ', i, ', Selected: ', gtk_tree_selection_path_is_selected(gtk_tree_view_get_selection(PGtkTreeView(FWidget)), Path)); - gtk_tree_path_free(Path); - Path := nil; - end; -// WriteLn('Selected: ', String(gtk_tree_path_to_string(Path))); - ConvertPathToChild(Path); -(* gtk_tree_model_get_iter_from_string(gtk_tree_view_get_model(PGtkTreeView(FWidget)){FTreeModelSort}, @Iter, gtk_tree_path_to_string(Path)); - gtk_tree_model_sort_convert_child_iter_to_iter(FTreeModelSort, @NewIter, @Iter); - Path := gtk_tree_model_get_path({FTreeModelSort}gtk_tree_view_get_model(PGtkTreeView(FWidget)), @NewIter); - *) -// gtk_tree_model_sort_clear_cache(FTreeModelSort); -// Path := gtk_tree_model_sort_convert_path_to_child_path(FTreeModelSort, Path); - end else begin - if not gtk_tree_selection_get_selected(gtk_tree_view_get_selection(PGtkTreeView(FWidget)), nil, @Iter) then Exit; - Path := gtk_tree_model_get_path(gtk_tree_view_get_model(PGtkTreeView(FWidget)), @iter); - if not Assigned(Path) then Exit; - ConvertPathToChild(Path); - end; + if not gtk_tree_selection_get_selected(gtk_tree_view_get_selection(PGtkTreeView(FWidget)), nil, @Iter) then Exit; + Path := gtk_tree_model_get_path(gtk_tree_view_get_model(PGtkTreeView(FWidget)), @iter); + if not Assigned(Path) then Exit; + ConvertPathToChild(Path); // WriteLn('Selected Converted: ', String(gtk_tree_path_to_string(Path))); if Assigned(Path) then begin - if Application.GTKVersion_2_0_5_Up then AIndex := gtk_tree_path_get_indices(Path)^ - else AIndex := StrToIntDef(String(gtk_tree_path_to_string(Path)), 0); + AIndex := gtk_tree_path_get_indices(Path)^; Result := Items[AIndex]; Result.FIndex := AIndex; gtk_tree_path_free(Path); @@ -643,8 +599,7 @@ begin if gtk_tree_view_get_path_at_pos(PGtkTreeView(FWidget), X, Y, Path, Column, nil, nil) then begin if not Assigned(Path) then Exit; ConvertPathToChild(Path); - if Application.GTKVersion_2_0_5_Up then AIndex := gtk_tree_path_get_indices(Path)^ - else AIndex := StrToIntDef(String(gtk_tree_path_to_string(Path)), 0); + AIndex := gtk_tree_path_get_indices(Path)^; Result := Items[AIndex]; Result.FIndex := AIndex; gtk_tree_path_free(Path); @@ -1029,8 +984,7 @@ begin DataColumn := TGTKTreeViewColumn(data).FIndex; Path := gtk_tree_path_new_from_string(path_string); if not Assigned(Path) then Exit; - if Application.GTKVersion_2_0_5_Up then AIndex := gtk_tree_path_get_indices(Path)^ - else AIndex := StrToIntDef(String(gtk_tree_path_to_string(Path)), 0); + AIndex := gtk_tree_path_get_indices(Path)^; TGTKTreeViewColumn(data).FOnEdited(TGTKTreeViewColumn(data), TGTKTreeViewColumn(data), ((TGTKTreeViewColumn(data).FOwner as TGTKTreeViewColumns).FOwner as TGTKListView).Items[AIndex], NewText, AllowChange, DataColumn); if AllowChange and (((TGTKTreeViewColumn(data).FOwner as TGTKTreeViewColumns).FOwner as TGTKListView).Items.Count < AIndex) then ((TGTKTreeViewColumn(data).FOwner as TGTKTreeViewColumns).FOwner as TGTKListView).Items[AIndex].SetValue(DataColumn, NewText); @@ -1045,8 +999,7 @@ begin if Assigned(data) and Assigned(TGTKTreeViewColumn(data).FOnToggled) then begin Path := gtk_tree_path_new_from_string(path_string); if not Assigned(Path) then Exit; - if Application.GTKVersion_2_0_5_Up then AIndex := gtk_tree_path_get_indices(Path)^ - else AIndex := StrToIntDef(String(gtk_tree_path_to_string(Path)), 0); + AIndex := gtk_tree_path_get_indices(Path)^; TGTKTreeViewColumn(data).FOnToggled(TGTKTreeViewColumn(data), TGTKTreeViewColumn(data), ((TGTKTreeViewColumn(data).FOwner as TGTKTreeViewColumns).FOwner as TGTKListView).Items[AIndex]); end; end; @@ -1267,12 +1220,6 @@ var Iter, NewIter: TGtkTreeIter; Path: PGtkTreePath; begin try - if not Application.GTKVersion_2_0_5_Up then begin - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(FIndex))); - ((FOwner as TGTKListItems).FOwner as TGTKView).ConvertChildToPath(Path); - gtk_tree_selection_select_path(((FOwner as TGTKListItems).FOwner as TGTKView).FSelection, Path); - gtk_tree_path_free(Path); - end else if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) then begin if Assigned(((FOwner as TGTKListItems).FOwner as TGTKView).FTreeModelSort) then begin gtk_tree_model_sort_convert_child_iter_to_iter(((FOwner as TGTKListItems).FOwner as TGTKView).FTreeModelSort, @NewIter, @Iter); @@ -1298,8 +1245,7 @@ begin Column := ((FOwner as TGTKListItems).FOwner as TGTKView).Columns[FocusColumnNo].FColumn; // Renderer := ((FOwner as TGTKListItems).FOwner as TGTKView).Columns[FocusColumnNo].FRenderer; -// if not Application.GTKVersion_2_0_5_Up then - for i := 1 to 2 do gtk_main_iteration_do(False); // This ugly piece of code HAVE TO BE HERE due some focus-related problems in GtkTreeView + for i := 1 to 2 do gtk_main_iteration_do(False); // This ugly piece of code HAVE TO BE HERE due some focus-related problems in GtkTreeView gtk_tree_view_set_cursor(PGtkTreeView(((FOwner as TGTKListItems).FOwner as TGTKView).FWidget), Path, Column, StartEditing); // gtk_tree_view_set_cursor(PGtkTreeView(((FOwner as TGTKListItems).FOwner as TGTKView).FWidget), Path, Column, StartEditing); // gtk_tree_view_set_cursor_on_cell(PGtkTreeView(((FOwner as TGTKListItems).FOwner as TGTKView).FWidget), Path, Column, Renderer, StartEditing); |
