Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'show' option to lxpanelctl. #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions man/lxpanelctl.1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ is a program that controls lxpanel\&.
Show the system menu\&.
.RE
.PP
\fBshow\fR
.RS 4
Show the panel in autohide mode\&.
.RE
.PP
\fBrun\fR
.RS 4
Show the run dialog\&.
Expand Down
3 changes: 3 additions & 0 deletions src/lxpanelctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const char usage[] =
"Usage: lxpanelctl <command>\n\n"
"Available commands:\n"
"menu\t\t\tshow system menu\n"
"show\t\t\tshow panel if hidden\n"
"run\t\t\tshow run dialog\n"
"config\t\t\tshow configuration dialog\n"
"restart\t\t\trestart lxpanel\n"
Expand All @@ -49,6 +50,8 @@ static int get_cmd( const char* cmd )
{
if( ! strcmp( cmd, "menu") )
return LXPANEL_CMD_SYS_MENU;
if( ! strcmp( cmd, "show") )
return LXPANEL_CMD_SHOW_PANEL;
else if( ! strcmp( cmd, "run") )
return LXPANEL_CMD_RUN;
else if( ! strcmp( cmd, "config") )
Expand Down
1 change: 1 addition & 0 deletions src/lxpanelctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
typedef enum {
LXPANEL_CMD_NONE,
LXPANEL_CMD_SYS_MENU,
LXPANEL_CMD_SHOW_PANEL,
LXPANEL_CMD_RUN,
LXPANEL_CMD_CONFIG,
LXPANEL_CMD_RESTART,
Expand Down
10 changes: 10 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ static void process_client_msg ( XClientMessageEvent* ev )
break;
}
#endif
case LXPANEL_CMD_SHOW_PANEL:
GSList* l;
for( l = all_panels; l; l = l->next )
{
LXPanel* p = (LXPanel*)l->data;

if (p->priv->box != NULL)
ah_show_panel(p);
}
break;
case LXPANEL_CMD_RUN:
gtk_run();
break;
Expand Down
15 changes: 15 additions & 0 deletions src/panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ static void _panel_update_background(LXPanel * p, gboolean enforce)

#define GAP 2
#define PERIOD 300
#define SHOW_PERIOD 3000

typedef enum
{
Expand Down Expand Up @@ -966,6 +967,9 @@ mouse_watch(LXPanel *panel)
if (p->move_state != PANEL_MOVE_STOP)
/* prevent autohide when dragging is on */
return TRUE;
if (p->hide_timeout != 0)
/* Wait for hidden timeout */
return TRUE;

if (cw == 1) cw = 0;
if (ch == 1) ch = 0;
Expand Down Expand Up @@ -1075,6 +1079,17 @@ static void ah_state_set(LXPanel *panel, PanelAHState ah_state)
RET();
}

/* Show panel if it is hidden */
void ah_show_panel(LXPanel *p)
{
ENTER;
if (!p->priv->visible) {
ah_state_set(p, AH_STATE_VISIBLE);
p->priv->hide_timeout = g_timeout_add(SHOW_PERIOD, ah_state_hide_timeout, p);
}
RET();
}

/* starts autohide behaviour */
static void ah_start(LXPanel *p)
{
Expand Down
8 changes: 8 additions & 0 deletions src/panel.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ extern void lxpanel_draw_label_text_with_color(LXPanel * p, GtkWidget * label, c
*/
void lxpanel_config_save(LXPanel *p); /* defined in configurator.c */

/**
* ah_show_panel
* @p: a panel instance
*
* Under autohide mode, Show panel @p if it is hidden.
*/
void ah_show_panel(LXPanel *p);

/* Accessors APIs for Panel* */
extern GtkOrientation panel_get_orientation(LXPanel *panel);
extern gint panel_get_icon_size(LXPanel *panel);
Expand Down