View Issue Details

IDProjectCategoryView StatusLast Update
0027905LazarusLCLpublic2015-04-25 12:34
ReporterKazantsev Alexey Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.5 (SVN) 
Summary0027905: GTK2 menu separator item (patch)
DescriptionGTK2 menu separator item (patch)
TagsNo tags attached.
Fixed in Revision48843
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0024476 resolvedJuha Manninen submenu on separator crashes 

Activities

Kazantsev Alexey

2015-04-19 23:02

reporter  

gtk2wsmenus.pp.patch (2,918 bytes)   
Index: gtk2wsmenus.pp
===================================================================
--- gtk2wsmenus.pp	(revision 48779)
+++ gtk2wsmenus.pp	(working copy)
@@ -1,8 +1,8 @@
 { $Id$}
 {
  *****************************************************************************
- *                              Gtk2WSMenus.pp                               * 
- *                              --------------                               * 
+ *                              Gtk2WSMenus.pp                               *
+ *                              --------------                               *
  *                                                                           *
  *                                                                           *
  *****************************************************************************
@@ -308,7 +308,7 @@
 begin
   // create the menuitem widget (normal, check or radio)
   if AMenuItem.Caption = cLineCaption then // create separator
-    Widget := gtk_menu_item_new
+    Widget := gtk_separator_menu_item_new
   else
   if AMenuItem.RadioItem and not AMenuItem.HasIcon then
     Widget := gtk_radio_menu_item_new(nil)
@@ -336,8 +336,7 @@
   end;
 
   // set attributes (enabled and rightjustify)
-  gtk_widget_set_sensitive(Widget,
-                     AMenuItem.Enabled and (AMenuItem.Caption <> cLineCaption));
+  gtk_widget_set_sensitive(Widget, AMenuItem.Enabled);
   if AMenuItem.RightJustify then
     gtk_menu_item_right_justify(PGtkMenuItem(Widget));
 
@@ -366,10 +365,14 @@
 begin
   if not WSCheckMenuItem(AMenuItem, 'SetCaption') then
     Exit;
-  MenuItemWidget:={%H-}PGtkWidget(AMenuItem.Handle);
-  UpdateInnerMenuItem(AMenuItem,MenuItemWidget);
-  gtk_widget_set_sensitive({%H-}PGtkWidget(AMenuItem.Handle),
-                           AMenuItem.Enabled and (ACaption <> cLineCaption));
+  if gtk_is_separator_menu_item(PGTKWidget(AMenuItem.Handle)) Or (ACaption = cLineCaption) then
+   AMenuItem.RecreateHandle
+  else
+   begin
+    MenuItemWidget:={%H-}PGtkWidget(AMenuItem.Handle);
+    UpdateInnerMenuItem(AMenuItem,MenuItemWidget);
+    gtk_widget_set_sensitive({%H-}PGtkWidget(AMenuItem.Handle), AMenuItem.Enabled);
+   end;
 end;
 
 class procedure TGtk2WSMenuItem.SetShortCut(const AMenuItem: TMenuItem;
@@ -381,7 +384,7 @@
   //CurShift: TShiftState;
 begin
   if not WSCheckMenuItem(AMenuItem, 'SetShortCut') then  Exit;
-  
+
   // Temporary: At least it writes the names of the shortcuts
   UpdateInnerMenuItem(AMenuItem, {%H-}PGTKWidget(AMenuItem.Handle), ShortCutK1, ShortCutK2);
 
@@ -449,8 +452,7 @@
   Result := False;
   if not WSCheckMenuItem(AMenuItem, 'SetEnable') then
     Exit;
-  gtk_widget_set_sensitive({%H-}PGtkWidget(AMenuItem.Handle),
-                           Enabled and (AMenuItem.Caption <> cLineCaption));
+  gtk_widget_set_sensitive({%H-}PGtkWidget(AMenuItem.Handle), Enabled);
   Result := True;
 end;
 
gtk2wsmenus.pp.patch (2,918 bytes)   

Kazantsev Alexey

2015-04-19 23:03

reporter  

Zeljan Rikalo

2015-04-25 10:24

developer   ~0083201

Please test and close if ok. Thanks for the patch.

Kazantsev Alexey

2015-04-25 12:34

reporter   ~0083209

I tested it. Thank.

Issue History

Date Modified Username Field Change
2015-04-19 23:02 Kazantsev Alexey New Issue
2015-04-19 23:02 Kazantsev Alexey File Added: gtk2wsmenus.pp.patch
2015-04-19 23:03 Kazantsev Alexey File Added: gtk2_menu_separator_before_and_after.png
2015-04-20 08:29 Zeljan Rikalo Assigned To => Zeljan Rikalo
2015-04-20 08:29 Zeljan Rikalo Status new => assigned
2015-04-25 10:24 Zeljan Rikalo Fixed in Revision => 48843
2015-04-25 10:24 Zeljan Rikalo LazTarget => -
2015-04-25 10:24 Zeljan Rikalo Note Added: 0083201
2015-04-25 10:24 Zeljan Rikalo Status assigned => resolved
2015-04-25 10:24 Zeljan Rikalo Resolution open => fixed
2015-04-25 10:40 Zeljan Rikalo Relationship added related to 0024476
2015-04-25 12:34 Kazantsev Alexey Note Added: 0083209
2015-04-25 12:34 Kazantsev Alexey Status resolved => closed