Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
xfdesktop
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jeremy White
xfdesktop
Commits
5354543f
Commit
5354543f
authored
18 years ago
by
Jean-François Wauthy
Browse files
Options
Downloads
Patches
Plain Diff
add preview widget in icon filechooser
(Old svn revision: 22340)
parent
7d6e1a10
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
menueditor/menueditor-add-dialog.c
+27
-0
27 additions, 0 deletions
menueditor/menueditor-add-dialog.c
menueditor/menueditor-edit-dialog.c
+27
-0
27 additions, 0 deletions
menueditor/menueditor-edit-dialog.c
with
54 additions
and
0 deletions
menueditor/menueditor-add-dialog.c
+
27
−
0
View file @
5354543f
...
...
@@ -51,6 +51,7 @@ typedef struct {
static
void
menueditor_add_dialog_class_init
(
MenuEditorAddDialogClass
*
);
static
void
menueditor_add_dialog_init
(
MenuEditorAddDialog
*
);
static
void
cb_chooser_icon_update_preview
(
GtkFileChooser
*
,
GtkImage
*
);
static
void
cb_browse_button_clicked
(
GtkButton
*
,
MenuEditorAddDialog
*
);
static
void
cb_combo_changed
(
GtkComboBox
*
,
MenuEditorAddDialog
*
);
static
void
cb_radio_button_themed_icon_toggled
(
GtkToggleButton
*
,
MenuEditorAddDialog
*
);
...
...
@@ -106,6 +107,7 @@ menueditor_add_dialog_init (MenuEditorAddDialog * dialog)
GtkWidget
*
hbox
;
GtkWidget
*
button_browse
;
GtkFileFilter
*
filter
;
GtkWidget
*
preview
;
GSList
*
radio_button_group
=
NULL
;
gtk_window_set_title
(
GTK_WINDOW
(
dialog
),
_
(
"Add menu entry"
));
...
...
@@ -227,6 +229,12 @@ menueditor_add_dialog_init (MenuEditorAddDialog * dialog)
gtk_file_chooser_add_filter
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
filter
);
gtk_file_chooser_set_filter
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
filter
);
preview
=
gtk_image_new
();
gtk_widget_show
(
preview
);
gtk_file_chooser_set_preview_widget
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
preview
);
gtk_file_chooser_set_preview_widget_active
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
TRUE
);
g_signal_connect
(
G_OBJECT
(
priv
->
chooser_icon
),
"update-preview"
,
G_CALLBACK
(
cb_chooser_icon_update_preview
),
preview
);
gtk_file_chooser_set_current_folder
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
DATADIR
"/icons"
);
gtk_widget_show
(
priv
->
chooser_icon
);
gtk_table_attach
(
GTK_TABLE
(
table
),
priv
->
chooser_icon
,
1
,
2
,
4
,
5
,
GTK_EXPAND
|
GTK_FILL
,
GTK_FILL
,
0
,
6
);
...
...
@@ -247,6 +255,25 @@ menueditor_add_dialog_init (MenuEditorAddDialog * dialog)
/*************/
/* internals */
/*************/
static
void
cb_chooser_icon_update_preview
(
GtkFileChooser
*
chooser
,
GtkImage
*
preview
)
{
gchar
*
filename
;
GdkPixbuf
*
pix
=
NULL
;
filename
=
gtk_file_chooser_get_filename
(
chooser
);
if
(
g_file_test
(
filename
,
G_FILE_TEST_IS_REGULAR
))
pix
=
gdk_pixbuf_new_from_file_at_size
(
filename
,
64
,
64
,
NULL
);
g_free
(
filename
);
if
(
G_IS_OBJECT
(
pix
))
{
gtk_image_set_from_pixbuf
(
preview
,
pix
);
g_object_unref
(
G_OBJECT
(
pix
));
}
gtk_file_chooser_set_preview_widget_active
(
chooser
,
G_IS_OBJECT
(
pix
));
}
static
void
cb_browse_button_clicked
(
GtkButton
*
button
,
MenuEditorAddDialog
*
dialog
)
{
...
...
This diff is collapsed.
Click to expand it.
menueditor/menueditor-edit-dialog.c
+
27
−
0
View file @
5354543f
...
...
@@ -50,6 +50,7 @@ typedef struct {
static
void
menueditor_edit_dialog_class_init
(
MenuEditorEditDialogClass
*
);
static
void
menueditor_edit_dialog_init
(
MenuEditorEditDialog
*
);
static
void
cb_chooser_icon_update_preview
(
GtkFileChooser
*
,
GtkImage
*
);
static
void
cb_browse_button_clicked
(
GtkButton
*
,
MenuEditorEditDialog
*
);
static
void
cb_radio_button_themed_icon_toggled
(
GtkToggleButton
*
,
MenuEditorEditDialog
*
);
static
void
cb_radio_button_icon_toggled
(
GtkToggleButton
*
,
MenuEditorEditDialog
*
);
...
...
@@ -102,6 +103,7 @@ menueditor_edit_dialog_init (MenuEditorEditDialog * dialog)
gchar
*
label_text
=
NULL
;
GtkWidget
*
button_browse
;
GtkFileFilter
*
filter
;
GtkWidget
*
preview
;
GSList
*
radio_button_group
=
NULL
;
gtk_window_set_title
(
GTK_WINDOW
(
dialog
),
_
(
"Edit menu entry"
));
...
...
@@ -203,6 +205,12 @@ menueditor_edit_dialog_init (MenuEditorEditDialog * dialog)
gtk_file_chooser_add_filter
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
filter
);
gtk_file_chooser_set_filter
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
filter
);
preview
=
gtk_image_new
();
gtk_widget_show
(
preview
);
gtk_file_chooser_set_preview_widget
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
preview
);
gtk_file_chooser_set_preview_widget_active
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
TRUE
);
g_signal_connect
(
G_OBJECT
(
priv
->
chooser_icon
),
"update-preview"
,
G_CALLBACK
(
cb_chooser_icon_update_preview
),
preview
);
gtk_file_chooser_set_current_folder
(
GTK_FILE_CHOOSER
(
priv
->
chooser_icon
),
DATADIR
"/icons"
);
gtk_widget_show
(
priv
->
chooser_icon
);
gtk_table_attach
(
GTK_TABLE
(
table
),
priv
->
chooser_icon
,
1
,
2
,
4
,
5
,
GTK_EXPAND
|
GTK_FILL
,
GTK_FILL
,
0
,
6
);
...
...
@@ -223,6 +231,25 @@ menueditor_edit_dialog_init (MenuEditorEditDialog * dialog)
/*************/
/* internals */
/*************/
static
void
cb_chooser_icon_update_preview
(
GtkFileChooser
*
chooser
,
GtkImage
*
preview
)
{
gchar
*
filename
;
GdkPixbuf
*
pix
=
NULL
;
filename
=
gtk_file_chooser_get_filename
(
chooser
);
if
(
g_file_test
(
filename
,
G_FILE_TEST_IS_REGULAR
))
pix
=
gdk_pixbuf_new_from_file_at_size
(
filename
,
64
,
64
,
NULL
);
g_free
(
filename
);
if
(
G_IS_OBJECT
(
pix
))
{
gtk_image_set_from_pixbuf
(
preview
,
pix
);
g_object_unref
(
G_OBJECT
(
pix
));
}
gtk_file_chooser_set_preview_widget_active
(
chooser
,
G_IS_OBJECT
(
pix
));
}
static
void
cb_browse_button_clicked
(
GtkButton
*
button
,
MenuEditorEditDialog
*
dialog
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment