Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
bf5248bc
Commit
bf5248bc
authored
Sep 11, 2009
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New functions to create and delete menu items
parent
49eea652
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
1 deletion
+140
-1
src/lib/co/gtk/co_wow_gtk.cpp
src/lib/co/gtk/co_wow_gtk.cpp
+138
-1
src/lib/co/gtk/co_wow_gtk.h
src/lib/co/gtk/co_wow_gtk.h
+2
-0
No files found.
src/lib/co/gtk/co_wow_gtk.cpp
View file @
bf5248bc
...
...
@@ -28,6 +28,7 @@
#include "pwr.h"
#include "co_wow_gtk.h"
#include "co_dcli.h"
#include "co_cdh.h"
#include "co_api.h"
#include "co_lng.h"
...
...
@@ -329,7 +330,7 @@ void *CoWowGtk::CreateList (
ctx
->
toplevel
=
(
GtkWidget
*
)
g_object_new
(
GTK_TYPE_WINDOW
,
"default-height"
,
400
,
"default-width"
,
200
,
"title"
,
t
itle
,
"title"
,
t
ranslate_utf8
(
title
)
,
"window-position"
,
GTK_WIN_POS_CENTER
,
NULL
);
...
...
@@ -1049,7 +1050,143 @@ int CoWowGtk::CreateModalDialog( const char *title, const char *text, const char
return
status
;
}
pwr_tStatus
CoWowGtk
::
CreateMenuItem
(
const
char
*
name
,
void
*
menu
,
int
pixmap
,
int
append
,
void
*
w
)
{
char
name_array
[
10
][
40
];
int
name_cnt
;
char
label
[
80
];
GtkWidget
*
child
;
pwr_tFileName
fname
;
name_cnt
=
dcli_parse
(
name
,
"-"
,
""
,
(
char
*
)
name_array
,
sizeof
(
name_array
)
/
sizeof
(
name_array
[
0
]),
sizeof
(
name_array
[
0
]),
0
);
if
(
!
name_cnt
)
return
0
;
if
(
name_cnt
==
1
)
{
if
(
pixmap
==
wow_ePixmap_No
||
pixmap
>=
wow_ePixmap__
)
*
(
GtkWidget
**
)
w
=
gtk_menu_item_new_with_label
(
translate_utf8
(
name_array
[
0
]));
else
{
*
(
GtkWidget
**
)
w
=
gtk_image_menu_item_new_with_label
(
translate_utf8
(
name_array
[
0
]));
switch
(
pixmap
)
{
case
wow_ePixmap_Graph
:
dcli_translate_filename
(
fname
,
"$pwr_exe/wtt_ge.png"
);
break
;
default:
dcli_translate_filename
(
fname
,
"$pwr_exe/wtt_ge.png"
);
}
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
*
(
GtkWidget
**
)
w
),
gtk_image_new_from_file
(
fname
));
}
if
(
append
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
),
*
(
GtkWidget
**
)
w
);
else
gtk_menu_shell_prepend
(
GTK_MENU_SHELL
(
menu
),
*
(
GtkWidget
**
)
w
);
gtk_widget_show
(
GTK_WIDGET
(
*
(
GtkWidget
**
)
w
));
}
else
{
// Find or create the parent menues
GtkContainer
*
parent
=
(
GtkContainer
*
)
menu
;
for
(
int
i
=
0
;
i
<
name_cnt
;
i
++
)
{
GList
*
chlist
=
gtk_container_get_children
(
GTK_CONTAINER
(
parent
));
int
found
=
0
;
for
(
GList
*
ch
=
chlist
;
ch
;
ch
=
ch
->
next
)
{
GtkWidget
*
labelw
=
gtk_bin_get_child
(
GTK_BIN
(
ch
->
data
));
strncpy
(
label
,
(
char
*
)
gtk_label_get_text
(
GTK_LABEL
(
labelw
)),
sizeof
(
label
));
if
(
cdh_NoCaseStrcmp
(
label
,
name_array
[
i
])
==
0
)
{
child
=
GTK_WIDGET
(
ch
->
data
);
found
=
1
;
break
;
}
}
if
(
!
found
)
{
// Create the menu item
GtkWidget
*
item
;
if
(
i
==
name_cnt
-
1
&&
pixmap
!=
wow_ePixmap_No
&&
pixmap
<=
wow_ePixmap__
)
{
item
=
gtk_image_menu_item_new_with_label
(
translate_utf8
(
name_array
[
i
]));
switch
(
pixmap
)
{
case
wow_ePixmap_Graph
:
dcli_translate_filename
(
fname
,
"$pwr_exe/wtt_ge.png"
);
break
;
default:
dcli_translate_filename
(
fname
,
"$pwr_exe/wtt_ge.png"
);
}
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
item
),
gtk_image_new_from_file
(
fname
));
}
else
item
=
gtk_menu_item_new_with_label
(
translate_utf8
(
name_array
[
i
]));
if
(
append
)
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
parent
),
item
);
else
gtk_menu_shell_prepend
(
GTK_MENU_SHELL
(
parent
),
item
);
gtk_widget_show
(
GTK_WIDGET
(
item
));
if
(
i
!=
name_cnt
-
1
)
{
GtkMenu
*
submenu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
item
),
GTK_WIDGET
(
submenu
));
parent
=
GTK_CONTAINER
(
submenu
);
gtk_widget_show
(
GTK_WIDGET
(
submenu
));
}
else
parent
=
(
GtkContainer
*
)
item
;
}
else
parent
=
(
GtkContainer
*
)
gtk_menu_item_get_submenu
(
GTK_MENU_ITEM
(
child
));
if
(
!
parent
)
return
0
;
g_list_free
(
chlist
);
}
*
(
GtkContainer
**
)
w
=
parent
;
}
return
1
;
}
pwr_tStatus
CoWowGtk
::
DeleteMenuItem
(
const
char
*
name
,
void
*
menu
)
{
char
name_array
[
10
][
40
];
int
name_cnt
;
char
label
[
80
];
GtkWidget
*
child
;
name_cnt
=
dcli_parse
(
name
,
"-"
,
""
,
(
char
*
)
name_array
,
sizeof
(
name_array
)
/
sizeof
(
name_array
[
0
]),
sizeof
(
name_array
[
0
]),
0
);
if
(
!
name_cnt
)
return
0
;
// Find the parent menues
GtkContainer
*
parent
=
(
GtkContainer
*
)
menu
;
for
(
int
i
=
0
;
i
<
name_cnt
;
i
++
)
{
GList
*
chlist
=
gtk_container_get_children
(
GTK_CONTAINER
(
parent
));
int
found
=
0
;
for
(
GList
*
ch
=
chlist
;
ch
;
ch
=
ch
->
next
)
{
GtkWidget
*
labelw
=
gtk_bin_get_child
(
GTK_BIN
(
ch
->
data
));
strncpy
(
label
,
(
char
*
)
gtk_label_get_text
(
GTK_LABEL
(
labelw
)),
sizeof
(
label
));
if
(
cdh_NoCaseStrcmp
(
label
,
name_array
[
i
])
==
0
)
{
child
=
GTK_WIDGET
(
ch
->
data
);
found
=
1
;
break
;
}
}
if
(
!
found
)
return
0
;
if
(
i
==
name_cnt
-
1
)
gtk_widget_destroy
(
child
);
else
parent
=
(
GtkContainer
*
)
gtk_menu_item_get_submenu
(
GTK_MENU_ITEM
(
child
));
if
(
!
parent
)
return
0
;
g_list_free
(
chlist
);
}
return
1
;
}
...
...
src/lib/co/gtk/co_wow_gtk.h
View file @
bf5248bc
...
...
@@ -108,6 +108,8 @@ class CoWowGtk : public CoWow {
const
char
*
button3
,
const
char
*
image
);
int
DisplayWarranty
();
void
DisplayLicense
();
pwr_tStatus
CreateMenuItem
(
const
char
*
name
,
void
*
menu
,
int
pixmap
,
int
append
,
void
*
w
);
pwr_tStatus
DeleteMenuItem
(
const
char
*
name
,
void
*
menu
);
CoWowTimer
*
timer_new
();
void
SetParent
(
GtkWidget
*
parent
)
{
m_parent
=
parent
;}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment