Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
yad
Commits
9952fd53
Commit
9952fd53
authored
Aug 04, 2019
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add application selection dialog
parent
a3a9c5e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
0 deletions
+113
-0
app.c
src/app.c
+113
-0
No files found.
src/app.c
0 → 100644
View file @
9952fd53
/*
* This file is part of YAD.
*
* YAD is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* YAD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with YAD. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2008-2019, Victor Ananjevsky <ananasik@gmail.com>
*/
#include "yad.h"
static
GtkWidget
*
app
;
static
void
app_activated_cb
(
GtkAppChooserWidget
*
w
,
GAppInfo
*
app
,
gpointer
d
)
{
if
(
options
.
plug
==
-
1
)
yad_exit
(
options
.
data
.
def_resp
);
}
GtkWidget
*
app_create_widget
(
GtkWidget
*
dlg
)
{
gchar
*
ctype
;
GtkWidget
*
w
;
if
(
options
.
extra_data
&&
*
options
.
extra_data
)
ctype
=
options
.
extra_data
[
0
];
else
ctype
=
"text/plain"
;
app
=
w
=
gtk_app_chooser_widget_new
(
ctype
);
gtk_widget_set_name
(
w
,
"yad-app-widget"
);
gtk_app_chooser_widget_set_show_default
(
GTK_APP_CHOOSER_WIDGET
(
w
),
TRUE
);
gtk_app_chooser_widget_set_show_recommended
(
GTK_APP_CHOOSER_WIDGET
(
w
),
TRUE
);
gtk_app_chooser_widget_set_show_fallback
(
GTK_APP_CHOOSER_WIDGET
(
w
),
options
.
app_data
.
show_fallback
);
gtk_app_chooser_widget_set_show_other
(
GTK_APP_CHOOSER_WIDGET
(
w
),
options
.
app_data
.
show_other
);
gtk_app_chooser_widget_set_show_all
(
GTK_APP_CHOOSER_WIDGET
(
w
),
options
.
app_data
.
show_all
);
g_signal_connect
(
G_OBJECT
(
w
),
"application-activated"
,
G_CALLBACK
(
app_activated_cb
),
NULL
);
return
w
;
}
void
app_print_result
(
void
)
{
GAppInfo
*
info
=
gtk_app_chooser_get_app_info
(
GTK_APP_CHOOSER
(
app
));
if
(
info
)
{
if
(
options
.
app_data
.
extended
)
{
if
(
options
.
common_data
.
quoted_output
)
{
gchar
*
buf
;
buf
=
g_shell_quote
(
g_app_info_get_name
(
info
));
g_printf
(
"%s%s"
,
buf
,
options
.
common_data
.
separator
);
g_free
(
buf
);
buf
=
g_shell_quote
(
g_app_info_get_display_name
(
info
));
g_printf
(
"%s%s"
,
buf
,
options
.
common_data
.
separator
);
g_free
(
buf
);
buf
=
g_shell_quote
(
g_app_info_get_description
(
info
));
g_printf
(
"%s%s"
,
buf
,
options
.
common_data
.
separator
);
g_free
(
buf
);
buf
=
g_shell_quote
(
g_icon_to_string
(
g_app_info_get_icon
(
info
)));
g_printf
(
"%s%s"
,
buf
,
options
.
common_data
.
separator
);
g_free
(
buf
);
buf
=
g_shell_quote
(
g_app_info_get_executable
(
info
));
g_printf
(
"%s%s"
,
buf
,
options
.
common_data
.
separator
);
g_free
(
buf
);
g_printf
(
"
\n
"
);
}
else
{
g_printf
(
"%s%s%s%s%s%s%s%s%s%s
\n
"
,
g_app_info_get_name
(
info
),
options
.
common_data
.
separator
,
g_app_info_get_display_name
(
info
),
options
.
common_data
.
separator
,
g_app_info_get_description
(
info
),
options
.
common_data
.
separator
,
g_icon_to_string
(
g_app_info_get_icon
(
info
)),
options
.
common_data
.
separator
,
g_app_info_get_executable
(
info
),
options
.
common_data
.
separator
);
}
}
else
{
if
(
options
.
common_data
.
quoted_output
)
{
gchar
*
buf
=
g_shell_quote
(
g_app_info_get_executable
(
info
));
g_printf
(
"%s
\n
"
,
buf
);
g_free
(
buf
);
}
else
g_printf
(
"%s
\n
"
,
g_app_info_get_executable
(
info
));
}
}
}
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